string Date(string format [, int timestamp])
The parameter format represents the way the time is formatted, possibly in the following way:
Description of formatting methods
y 4 digit year, Y is 2 digits, e.g. 99 is 1999
m Digit month, preceded by a leading 0, such as 01. N is no leading 0 digit month
F Month, full text format, such as January or March
M Three-letter abbreviation for the month, such as Jan or Mar
the day of the D-month preceded by a leading 0, such as 03. J is a number of days without leading 0
The day of the W week, expressed as a number, 0 means Sunday
The day ordinal of the Z-year, range 0-366
the first week of the W year, such as the 32nd week
H 24-hour format with leading 0,h for 12-hour format
G 24-hour format, no preamble 0,g for corresponding 12-hour format
i-minute format with leading 0
S-second format with leading 0
A Uppercase in the afternoon, such as am,a for lowercase
an optional parameter, timestamp, represents a timestamp, which defaults to time (), which is the current timestamp.
We can display the required time and date using the rich formatting provided by the date () function, as in the following example:
date ("Y-m-d", Time ()); Display format such as 2008-12-01
date ("Y.m.d", Time ()); Display format such as 2008.12.01
Date ("M D Y", Time ()); Display formats like Dec
date ("Y-m-d h:i", Time ()); Display formats such as 2008-12-01 12:01
Tips
If you output the time and the actual difference of 8 hours (assuming you use the Beijing time zone), please check the php.ini file, do the following settings:
Date.timezone = PRC
Mktime(Hour, minute, second, month, day, year) gets the timestamp from the date, returns the timestamp successfully, otherwise returns false.
Parameters can be omitted from right to left, and any omitted parameters are set to the current value of the cost date and time. and automatically calculates the correct value for the out-of-range input. The last day of any given month can be expressed as the "0" day of the next month, not 1 days.
Strtotime(String Time,[,int now]) converts any English text string representation of the date to a timestamp, which is the inverse of the date ().
PHP Common functions Time