This article mainly introduces the PHP date function brief and obtains the formulation time method, the interest friend's reference, hoped to be helpful to everybody.
The code is as follows:
echo "Today:". Date ("y-m-d"). " <br> "; echo "Yesterday:" Date ("y-m-d", Strtotime ("1 day"), "<br>"; echo "Tomorrow:". Date ("Y-m-d", Strtotime ("+1 Day")). " <br> "echo" A week later: ". Date (" Y-m-d ", Strtotime (" +1 Week "))." <br> "; echo "2 days a week four hours two seconds after:". Date ("Y-m-d g:h:s", Strtotime ("+1 Week 2 Day 4 hours 2 Seconds")). " <br> "; echo "Next week Four:". Date ("Y-m-d", Strtotime ("next Thursday")). " <br> "; echo "Previous Monday:". Date ("Y-m-d", Strtotime ("Last Monday")). " <br> "; echo "One months ago:". Date ("Y-m-d", Strtotime ("Last month"). " <br> "; echo "One months later:". Date ("Y-m-d", Strtotime ("+1 Month")). " <br> "; echo "Ten years later:". Date ("Y-m-d", Strtotime ("+10 Year")). " <br> "; The function of the Strtotime () function is to parse the datetime description into the Unix timestamp int strtotime (string time [, int now])
PHP Week Get Code:
The code is as follows:
Date ("L");//data can get English for weeks such as Sundaydate ("w");//This can get the number of weeks like 123, note that 0 is Sunday
Get Chinese week can be like this
The code is as follows:
$weekarray =array ("Day", "one", "two", "three", "four", "Five", "VI"); echo "Week". $weekarray [Date ("W")];
Gets the specified date:
$weekarray =array ("Day", "one", "two", "three", "four", "five", "six"); Echo "Week". $weekarray [Date ("W", "2011-11-11")];
Because the date function is so powerful, he can do all this work. I'm attaching a table in the handbook.
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 "31"
D-Days of the week, three English letters; such as: "Fri"
F-month, full name in English; such as: "January"
H-12 hours of the hour; such as: "01" to "12"
H-hour of 24-hour system; such as: "00" to "23"
G-12 hours of the hour, less than two digits do not fill 0; such as: "1" to 12 "
G-24 hours of the hour, less than two does not fill 0; such as: "0" to "23"
I-minute; such as: "00" to "59"
J-A few days, two digits, if less than two bits do not fill 0; such as: "1" to "31"
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 "12"
N-month, two digits, if less than two digits does not fill 0; such as: "1" to "12"
M-month, three letters of English; such as: "Jan"
S-second; such as: "00" to "59"
S-End With English ordinal number, two English letters; such as: "th", "nd"
T-the number of days in the specified month; such as: "28" to "31"
U-Total number of seconds
W-Number of days of the week, such as: "0" (Sunday) to "6" (Saturday)
Y-year, four digits; such as: "1999"
Y-year, two digits; such as: "99"
Z-the day ordinal of a year; such as: "0" to "365"
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
PHP for user query and judgment
PHP regular match and array traversal
PHP operations for creating, deleting, copying, and checking files and directories