PHP date () function detailed parameters

Source: Internet
Author: User
Add date_default_timezone_set (PRC) to the front of the page );  /*  Change the time to Beijing time. The default PhP5 time is Greenwich Mean Time.  */  Date  () : "Am" or "PM" A : "Am" or "PM" D : Day (s), double-digit characters. If not, zeros are added. From "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-hour, 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, not zero; from "1" to "31" 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, with three English letters, for example, "Jan" S : Seconds; from "00" to "59" S : Ending with an English sequence, two English letters, for example, "21th" T : Specifies the number of days of the 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 indicates that the year can be written in uppercase y and lowercase y; month can be written in uppercase F, uppercase M, lowercase m, and lowercase N (two types of characters and numbers respectively ); indicates the date suffix.  Echo   Date ('Y-m-J' ); 2007-02-6 Echo   Date ('Y-n-J' ); 07-2-6Uppercase 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-6 Echo   Date ('Y-m-d' ); 2007-02-06 Uppercase M indicates the three abbreviated characters of the month, while lowercase M indicates the number of the month (with the leading 0). Without uppercase J, only lowercase J indicates the date of the month, no leading O; Use lowercase d if the month has a leading character.  Echo   Date ('Y-m-J' ); 2007-feb-6 Echo   Date ('Y-F-js'); 2007-February- 6 th Capital M indicates the three characters of the month, while F indicates the English full write of the month. (No lowercase f) uppercase s indicates the suffix of the 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 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 ".  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. uppercase h indicates the number of hours in the 24-hour format. Summary: the letter G indicates that the hour does not contain the leading value, the letter h indicates the hour with the leading; the lowercase G, H indicates the 12-hour system, and the upper case G, H indicates the 24-hour system. 3 , Leap year, week, day  Echo   Date ('L' ); Whether this year is a leap year: 0 Echo   Date ('L' ); Today is: Tuesday  Echo   Date ('D'); Today is: Tue capital L indicates whether this year is a leap year, Boolean value, True returns 1, otherwise it is 0; lowercase L indicates the day of the week in English (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 first day of the year 06 Weekly lowercase W indicates the day of the week, and numeric indicates the number of weeks in a year.  Echo   Date ('T' ); This month is 28 Days  Echo   Date ('Z' ); Today is the first day of this year 36 Day lowercase t indicates the number of days in the current month. Z indicates the day in the current year. 4 , Other  Echo   Date ('T' ); UTC capital T indicates the time zone setting of the server  Echo   Date ('I' ); 0 If I is used to determine whether the current value is success, 1 is returned for true. Otherwise, 0 is returned.  Echo   Date ('U' ); 1170769424The 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 indicates the iso8601 date, in the format of yyyy -MM-DD, separated by the letter T, date and time, in the format of HH: mm: SS, the time zone is expressed by the deviation of Greenwich Mean Time (GMT.  Echo   Date ('R' ); TUE , 06 Feb 2007 14:25:52 + 0000 Lowercase R indicates the rfc822 date. 5 , Format time  Echo   $ Row ["T_time"]; returns 12:08:00 Echo   Date ("Y-m-d ", Strtotime ( $ Row ["T_time "]). Note that because  $ Row ["T_time"] The obtained time is already a string, so you need to use strtotime (string-to-timestamp) to go through it. Otherwise, the error 1970-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.