Home > Article > Backend Development > A bunch of date and time operations in php
Format date and time
date : Format Date and time
Scenario
Format the current date and time or a specific date and time ##The output is a string in a specific format, often used for humanized display of information.
Description
Remarks
Description | Return value example | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Y
| 4 Complete year with digits | 2019
| ||||||||||||||||||||
| 2 Year represented by digits
| 19
| ||||||||||||||||||||
Three-letter abbreviation for the month | Jan to Dec |
| ##m||||||||||||||||||||
The month represented by the number, with leading zeros
| 01 to 12 # #D | |||||||||||||||||||||
3 letters | Mon to Sun
| d | ||||||||||||||||||||
2 digits with leading zeros | 01 to 31
| H | ||||||||||||||||||||
24 hour format, with leading zeros | 00 to 23
| h | ||||||||||||||||||||
12 hour format, with leading zeros | 01 to 12
| I | ||||||||||||||||||||
If so Daylight saving time is 1 | , otherwise it is 0 |
##i | ||||||||||||||||||||
00 to 59 | S | |||||||||||||||||||||
characters
| st,nd,rd or th , can be used together with | j
s | ||||||||||||||||||||
00 to 59 | ## |
Description | Parameter example | |
---|---|---|
| hour Number of hours
| 00 to 23
|
minute | Minutes 00 to 59 |
| ##s
second Number of seconds | 00 to 59 | # #n |
month Number of months | 01 to 12
| ## j |
Number of days
| 01 to 31
| ##Y
|
0-69 | corresponds to 2000-2069 , 70-100 | corresponds to 1970-2000
|
The above is the detailed content of A bunch of date and time operations in php. For more information, please follow other related articles on the PHP Chinese website!