PHP date () function detailed parameters

Source: Internet
Author: User
Tags ranges

Add
Date_default_timezone_set (PRC);/* set the time to Beijing Time, and PhP5 is the Greenwich Mean Time by default */
Date () A: "am" or "PM"
A: "am" or "PM"
D: day (s), double-digit number. If it is not enough, it will be zero. From "01" to "31"
D: The day of the week. Three English letters, for example, "fri"
F: Month, full English name, for example, "January"
H: hour in 12-hour format, from "01" to "12"
H: hour in 24-hour format, from "00" to "23"
G: The hour in 12-hour format. The value ranges from "1" to "12"
G: The hour in the 24-hour format. The value ranges from 0 to 23"
J: a few days. The number of days from "1" to "31" is not zero"
L: the day of the week. Full English name, for example, "Friday"
M: Month, double digit, from "01" to "12"
N: Month, double digit, not zero; from "1" to "12"
M: month, 3 English letters; for example: "Jan"
S: seconds; from "00" to "59"
S: The end of the word is followed by an English ordinal number. There are two English letters, for example, "21th"
T: specifies the number of days in a month, from "28" to "31"
U: Total number of seconds
W: number of weeks, from "0 (Sunday)" to "6 (Saturday )"
Y: year, four digits
Y: year, double digit
Z: The day of the year; from "1" to "366"
========================================================== ======================================
1, year-month-day
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. Echo date ('Y-m-J ');
2007-02-6echo 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. Echo date ('Y-m-J ');
2007-feb-6echo date ('Y-m-d ');
Uppercase m represents the three abbreviations of the month, while lowercase m represents the number of the month (with the 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. Echo date ('Y-m-J ');
2007-feb-6echo date ('Y-F-js ');
2007-february-6th upper case m represents the three abbreviations of the month, while upper case F represents 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. 2, hour: minute: by default, PHP interprets the display time as "Greenwich Mean Time", which is 8 hours different from our local time. Echo date ('G: I: s ');
5:56:57 amecho 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 the 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 ". Echo date ('G: I: s ');
14:02:26 uppercase G indicates the number of hours in the 24-hour format, but does not contain the leading value. h indicates the number of hours in the 24-hour format with the leading value:
The letter G indicates that the hour does not contain a leading character, and the letter h indicates that the hour contains a leading character;
Lowercase G and H are in 12-hour format, while uppercase G and H are in 24-hour format. 3. leap year, Week, and day echo date ('l ');
This year's leap year: 0 echo date ('l ');
Today is: tuesdayecho date ('D ');
Today is: Tue capital L indicates to judge whether this year is a leap year, Boolean value, returns 1 if true, otherwise it is 0;
Lowercase L indicates the day of the week in full (Tuesday );
However, uppercase D is used to represent the three abbreviation of the day of the week (Tue ). Echo date ('W ');
Today's week: 2 Echo date ('W ');
This week is the second week of the year. In lower case, W indicates the day of the week, which is expressed in numbers.
Uppercase W indicates the number of weeks in a year ECHO date ('T ');
This month is the 28-day echo date ('Z ');
Today is the second day of this year. lowercase t indicates the number of days in the current month.
Lowercase Z indicates the day 4 of the current year.
Echo date ('T ');
UTC
Uppercase t indicates that the server's time zone is set to echo date ('I ');
0
If I is used to determine whether the current value is success, 1 is returned for true; otherwise, 0 echo date ('U') is returned ');
1170769424
The upper-case u table shows the total number of seconds from January 1, January 1, 1970 to the present, which is the Unix timestamp of the UNIX time era. Echo date ('C ');
2007-02-06t14: 24: 43 + 00: 00
Lowercase c Represents the iso8601 date, the date format is YYYY-MM-DD, with the letter T to interval the date and time, the time format is hh: mm: SS, the time zone uses Greenwich Mean Time (GMT). Echo date ('R ');
Tue, 06 Feb 2007 14:25:52 + 0000
Lowercase R indicates the rfc822 date.
5. format the time
Echo $ row ["t_time"]; returns 12:08:00
Echo date ("Y-m-d", strtotime ($ row ["t_time"]); returns

Note: because the time obtained by $ row ["t_time"] is already a string, you need to use strtotime (string to timestamp) to convert it. Otherwise, the error-01-01 will be output.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.