[PHP] Back to basics (date function and Strtotime function), datestrtotime
Date (): Format a local time or date, current time May 13, 2016 15:19:49
Using the function date (), the output is currently the day ordinal of the month, parameter: string Type D
For example: Echo date ("D"); Output 13
Using the function date (), the output is currently the day ordinal of the week, parameter: String type D or N
For example: Echo date ("D"); Output Fri
echo Date ("N"); Output 5
echo Date ("L"); Output Friday
Use the function date () to output the month ordinal of the current month, parameter: String type N
echo Date ("n"); Output 5
Use the function date () to determine whether the current year is a leap years, parameter: String type L
echo Date ("L"); Output 1
Strtotime (): Turns the string type date format into a timestamp
Use function Strtotime () to print the date of the previous day, parameter: String type "1 day"
echo Date ("Y-m-d h:i:s", Strtotime (" -1day")); output 2016-05-12 15:27:33
Use function Strtotime () to print tomorrow's date, parameter: String type "+1 Day"
echo Date ("Y-m-d h:i:s", Strtotime ("+1 Day"); output 2016-05-14 15:28:29
Use the function strtotime () to print the next Sunday period, Parameters: String Type "+1 Week"
echo Date ("Y-m-d h:i:s", Strtotime ("+1 Week"));; Output 2016-05-20 15:29:35
Use the function strtotime () to print the next one-month date, parameter: String type "+1 Month"
echo Date ("Y-m-d h:i:s", Strtotime ("+1 Month")); Output: 2016-06-13 15:37:42
Using function Strtotime (), Print next week 1st, parameter: String type "last Mondy"
echo Date ("Y-m-d h:i:s", Strtotime ("Next Monday")); Output: 2016-05-16 00:00:00
Use function Strtotime (), Print next week 2 days, two hours, two seconds later date, parameter: String type combination
echo Date ("Y-m-d h:i:s", Strtotime ("+1 Week 2 Day 2 Hour")); Output 2016-05-22 17:34:34
==================================================================
Java Edition:
Java.util.Date class
Get Date object, new out
Call the GetTime () method of the Date object to get the timestamp (millisecond value)
Java.text.SimpleDateFormat class
Get SimpleDateFormat object, new out, construct parameter: "Yyyy-mm-dd hh:mm:ss"
Call the format () method of the SimpleDateFormat object to get a string of type date, parameter: Date Object
For example:
Date Date=new date ();
SimpleDateFormat format=new SimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");
System.out.println (Format.format (date));
http://www.bkjia.com/PHPjc/1125993.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125993.html techarticle [PHP] Back to basics (date function and Strtotime function), Datestrtotime date (): Format a local time or date, current time May 13, 2016 15:19:49 use function date (), Lose ...