PHP date function parameters

Source: Internet
Author: User
: This article mainly introduces the date function parameters of PHP. For more information about PHP tutorials, see.
Add date_default_timezone_set ('prc') to the front page of the page;/* Set the time to Beijing time. php5 defaults to Greenwich Mean Time */date (): "am" or "pm" A: "AM" or "PM" d: days, double digits. if not, add zero. from "01" to "31" D: the day of the week, with three English letters, such as: "Fri" F: Month, full English name, such as: "January" h: 12-hour, from "01" to "12" H: 24 hours, from "00" to "23" g: 12 hours, no zeros; from "1" to "12" G: Hour in 24-hour format, do not fill in zero; from "0" to "23" j: A few days, not zero; from "1" to "31" l: Day of the week, full English name, such as: "Friday" m: month, two digits, 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: English Ordinal number, two English letters, such as: "21th" t: specifies the number of days of the month, from "28" to "31" U: total number of seconds w: Number of the day of the week, from "0 (Sunday)" to "6 (Saturday)" Y: year, four digits y: year, two digits z: The day of the year; from "1" to "366" ================================ ====================================== 1, year-month-day indicates that the year can be uppercase Y and lowercase y; indicates that a month can be written in uppercase letters (F), uppercase letters (M), lowercase letters (m), and lowercase letters (n). It can be written in lowercase letters (d) and lowercase letters (j, uppercase S indicates the suffix of the date. Echodate ('Y-m-J'); 2007-02-6echodate ('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. Echodate ('Y-M-J'); 2007-Feb-6echodate ('Y-m-D'); 2007-02-06 Capital M indicates three abbreviations of the month, in lower case, m indicates the number of the month (with the leading 0); in less Case, J indicates the date of the month, and no leading o; use lowercase d if the month has a prefix. Echodate ('Y-M-J'); 2007-Feb-6echodate ('Y-F-js'); 2007-February-6th Capital M indicates the three abbreviations of the month, in upper case, 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. Echodate ('G: I: s a'); 5:56:57 amechodate ('H: I: s a'); 05:56:57 AM lowercase g indicates 12-hour, no leading 0, the lower-case h indicates that there is a 12-hour 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 ". Echodate ('G: I: s'); 14:02:26 uppercase G indicates the number of hours in the 24-hour format, but without leading; use uppercase H to indicate the number of hours in the 24-hour format with the leading character. the Letter g indicates that the hour does not have the leading character, and the letter h indicates that the hour has the leading character. the lowercase g and h indicate that the 12-hour format, uppercase G and H indicate the 24-hour format. 3. leap year, week, and day echodate ('L'); this year's leap year: 0 echodate ('L'); today is: Tuesdayechodate ('D'); today is: tue capital L indicates whether the year is leap year, Boolean value, true returns 1; otherwise, 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 ). Echodate ('w'); today's week: 2 echodate ('w'); this week is the first week of the year. lowercase w indicates the day of the week, in the digit format, W indicates the number of weeks in a year ('t'); this month is 28 days ('Z '); today is the second day of this year. lowercase t indicates the number of days in the current month. lowercase z indicates that today is the fourth day of this year. other echodate ('t '); UTC capital T indicates that echodate ('I') is set for the time zone of the server; 0 capital I indicates that 1 is returned if the current value is success; otherwise, 0 echodate ('u') is returned '); 1170769424 indicates the total number of seconds from January 1, January 1, 1970 to the present, which is the Unix timestamp of the UNIX time era. Echodate ('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 separate the date and time, the time format is HH: MM: SS, and the time zone is expressed by GMT deviation. Echodate ('r'); Tue, 06 Feb 2007 14:25:52 + 0000 lowercase r indicates the RFC822 date. 5. the formatting time echo $ row ["t_time"]; will output 12: 08: 00 echodate ("Y-m-d ", strtotime ($ row ["t_time"]); returns the note. because the time obtained by $ row ["t_time"] is already a string, therefore, you need to use strtotime (string to timestamp) to convert it. Otherwise, the error "1970-01-01" will be output.

The preceding section describes the date function parameters of PHP, including related content. if you are interested in the PHP Tutorial.

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.