Detailed description of the date () function in php (12 ). Next we will introduce some usage and basic details about the date () function in php. The date function usage code is as follows: Copy the code date ($ t). The format is as follows: the display format. here we will introduce some usage and basic details about the date () function in php, for more information, see.
Date function usage
The code is as follows: |
|
Date ($ t ); |
The format is as follows:
Format: year-month-day hour: minute: Second
Related time parameters:
A-"am" or "pm"
A-"AM" or "PM"
D-a few days, two digits. if there are less than two digits, fill in the first zero. for example, "01" to "31"
D-the day of the week, with three English letters, for example, "Fri"
F-month, full English name; for example: "January"
H-12 hours, for example, "01" to "12"
H-24 hours, for example, "00" to "23"
Hours in the g-12 hour format. less than two hours do not fill in zero. for example: "1" to 12"
Hours in the G-24-hour format. less than two hours do not fill in zero. for example: "0" to "23"
I-minutes; for example: "00" to "59"
J-a few days, two digits. if less than two digits are left blank, for example, "1" to "31"
L-the day of the week, full name in English; for example: "Friday"
M-month, two digits. if there are less than two digits, add zero in front, for example, "01" to "12"
N-month, two digits. if less than two digits are left blank, for example, "1" to "12"
M-month, with three English letters, for example, "Jan"
S-seconds; for example: "00" to "59"
The end of the S-character is followed by an English sequence, with two English letters, for example, "th", "nd"
T-specifies the number of days in a month, for example, "28" to "31"
U-total seconds
W-number of weeks, for example, "0" (Sunday) to "6" (Saturday)
Y-year, four digits, such as: "1999"
Y-year, two digits, for example, "99"
Z-the day of the year, for example, "0" to "365"
You can freely set the displayed content, connection symbols, or display locations, such as date ("m-d H") or date ("dmY");?> Such as date processing in php
Instance
1, year-month-day
The code is as follows: |
|
Echo date ('Y-m-J '); 2007-02-6 Echo date ('Y-n-J ');
07-2-6 |
Uppercase Y indicates four digits of the year, while lowercase y indicates two digits of the year;
Lowercase m indicates the number of the month (with the leading digit), while lowercase n indicates the number of the month without the leading digit.
The code is as follows: |
|
Echo date ('Y-M-J '); 2007-Feb-6 Echo date ('Y-m-D '); 2007-02-06 |
Uppercase M indicates the three abbreviations of the month, while lowercase m indicates the number of the month (with leading 0 );
There is no upper-case J. only lower-case j indicates the date of the month, and there is no leading o. if the month needs to have the upper-case J, the lower-case d is used.
The code is as follows: |
|
Echo date ('Y-M-J '); 2007-Feb-6 Echo date ('Y-F-js '); 2007-February-6th |
Uppercase M indicates the three abbreviated characters of the month, while uppercase F indicates the full English writing of the month. (No lower case f)
Uppercase S indicates the suffix of a date, such as "st", "nd", "rd", and "th". for details, see the date number.
Summary:
Y indicates that the year can be in uppercase or lowercase y;
Indicates that the month can be written in uppercase letters (F), uppercase letters (M), lowercase letters (m), and lowercase letters (n );
Indicates the date suffix.
2, hour: minute: Second
By default, PHP interprets the display time as "Greenwich Mean Time", which is 8 hours different from our local time.
The code is as follows: |
|
Echo date ('G: I: s '); 5:56:57 am Echo date ('H: I: s '); 05:56:57 AM |
Lowercase g indicates the 12-hour system, with no leading 0, while lowercase h indicates the 12-hour system with leading 0.
When the 12-hour format is used, it indicates that upper afternoon, lower case a indicates lower case "am" and "pm", and upper case A indicates upper case "AM" and "PM ".
The code is as follows: |
|
Echo date ('G: I: s '); 14:02:26 |
1 2
For more information about the usage and basic description of lift () functions, see. The date function usage code is as follows: date ($ t); format: Display format...