The date and time in PHP are mainly by the date () function to get and format, although the use of this thing is very high frequency, but sometimes forget or confuse, it is summarized as follows ...
One, year/month/day
1, year
Y (2010): Uppercase y denotes year four digits
Y (10): lowercase y represents two digits of the year
2, Month
F (January): uppercase F denotes full written English for the month (no lowercase f)
M (Jan): Capital M denotes 3 abbreviated characters of the month
M (01-12): lowercase m represents the number of months with leading
N (1-12): lowercase n Indicates the number of months, no leading
3, Japan
J (1-31): Lowercase J Indicates the date of the month, no leading (no uppercase J)
D (01-31): Lowercase d Indicates the date of the month with a leading (no uppercase D)
S (St, ND, RD, TH): uppercase S denotes the suffix of the date, and the date number
4. Example
Y-m-j (2007-02-6)
Y-n-j (07-2-6)
Y-m-j (2007-feb-6)
Y-m-d (2007-02-06)
Y-f-js (2007-february-6th)
Second, time: minutes: seconds
1. When
G (1-12): lowercase g denotes 12-hour hours without leading 0
H (01-12): Lowercase h indicates 12-hour hours with leading 0
G (0-23): Uppercase G denotes 24-hour hours without leading 0
H (01-23): Uppercase H denotes 24-hour hours with leading 0
A represents lowercase "am" and "PM" (morning, afternoon)
A denotes uppercase "AM" and "PM"
2, minutes: seconds
By default, the PHP interpretation is displayed as "Greenwich Mean Time", which differs from our local time by 8 hours.
I (1-60): lowercase i denotes minute
S (1-60): lowercase s = seconds
3. Example
G:i:s A (5:56:57 am)
H:i:s A (05:56:57 AM)
G:i:s (14:02:26)
Iii. leap Year, Day of the week, days
Uppercase L Indicates whether this year's leap years, Boolean value, returns 1, otherwise 0
The lowercase w represents the day of the week, and the numeric representation
Uppercase W indicates the number of weeks in a year
Lowercase t indicates how many days are in the current month
Lowercase z indicates that today is the first day of the year
Iv. Other
An uppercase T represents the server's time zone setting, such as a value of UTC
Uppercase I indicates whether the current is daylight saving time, returns 1 for true, otherwise 0
The capital U represents the total number of seconds from January 1, 1970 to the present, which is the UNIX timestamp for the Unix time era.
The lowercase c represents the ISO8601 date, the date format is YYYY-MM-DD, the date and time are separated by the letter T, the time format is HH:MM:SS, and the time zone is expressed as a deviation of Greenwich Mean Time (GMT), such as a value of 2007-02-06t14:24:43+00:00
The lowercase R represents the RFC822 date, if the value is Tue, 2007 14:25:52 +0000