Parameters of the date function in PHP

Source: Internet
Author: User
Tags echo date
Time () is a number in PHP that indicates how many seconds have gone from 1970-01-01 to now, it's weird.
But it's easy to calculate,

To find out the day before is time () -60*60*24;
To find out when the previous year was time () *60*60*24*365

So how to change this number into a date format, it's going to use the date function.

$t =time ();  echo Date ("Y-m-d h:i:s", $t);

The format of the first parameter means:
A-"AM" or "PM"
A-"AM" or "PM"
D-a few days, two digits, if less than two is the front 0, such as: "01" to "seven"
D-Day of the week, three letters of English; such as: "Fri"
F-month, English full name, such as: "January"
h-12 hours of the hour, such as: "01" to "a"
H-24 hours of the hour, such as: "00" to ""
g-12-hour system Hours, less than two digits do not fill 0; such as: "1" to "
G-24 hours, less than two digits do not fill 0, such as:" 0 "to"
I-minute, such as: "00" to "the"
J-A few days, two digits, if less than two digits do not fill 0, such as: "1" to "31" Br>l-Day of the week, English full name; such as: "Friday"
M-month, two digits, if less than two digits in front of 0, such as: "01" to "Nine"
N-month, two digits, if less than two digits do not fill 0, such as: "1" to "seven"
M-month, three English letters, such as: "Ja N "
S-second;" 00 "to" a "
S-tail with English ordinal number, two English letters, such as:" th "," nd "
T-Specify the number of days of the month, such as:" 28 "to" + "
U-Total seconds
W-Digital type The day of the week, such as: "0" (Sunday) to "6" (Saturday)
Y-year, four digits, such as: "1999"
Y-year, two digits, such as: "" "
Z-Days of the year, such as:" 0 "to" 365 "
Other not listed above Character lists the character directly

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.