This article mainly introduced the PHP date function commonly used time processing method, this article introduced obtains today, tomorrow, yesterday, one week, one months ago, one months after time method, needs the friend to be possible to refer to under
The code is as follows:
echo "Today:". Date ("y-m-d"). "
";
echo "Yesterday:". Date ("Y-m-d", Strtotime ("-1 Day"), "
";
echo "Tomorrow:". Date ("Y-m-d", Strtotime ("+1 Day"). "
";
echo "A week later:". Date ("Y-m-d", Strtotime ("+1 Week")). "
";
echo "2 days a week four hours two seconds later:". Date ("Y-m-d g:h:s", Strtotime ("+1 Week 2 days 4 hours 2 Seconds")). "
";
echo "Next Monday Four:". Date ("Y-m-d", Strtotime ("next Thursday")). "
";
echo "Last Monday:". Date ("Y-m-d", Strtotime ("Monday")). "
";
echo "One months ago:". Date ("Y-m-d", Strtotime ("last month")). "
";
echo "One months later:". Date ("Y-m-d", Strtotime ("+1 Month")). "
";
echo "Ten years later:". Date ("Y-m-d", Strtotime ("+10 Year")). "
";
The strtotime () function resolves a date-time description to a Unix timestamp
int Strtotime (string time [, int now])
PHP Week to get code:
Copy code code as follows:
Date ("L");
Data will be available for English week like Sunday
Date ("W");
This can get a digital week like 123, note 0 is Sunday
Get Chinese week can be like this
Copy code code as follows:
$weekarray =array ("Day", "one", "two", "three", "four", "five", "six");
echo "Week". $weekarray [Date ("W")];
Get the specified date is:
[Code]
$weekarray =array ("Day", "one", "two", "three", "four", "five", "six");
echo "Week". $weekarray [Date ("W", "2011-11-11")];
Because the date function is very powerful, he is perfectly capable of doing all this work. I have a table in the manual.
A-"AM" or "PM"
A-"AM" or "PM"
D-A few days, two digits, if less than two digits before the 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"
Hours of h-12 hours; such as: "01" to "12"
H-24 hours of hours; such as: "00" to "23"
G-12 hours, less than two-bit not to fill 0; such as: "1" to 12 "
G-24 hours of hours, less than two to fill 0; such as: "0" to "23"
I-minute; such as: "00" to "59"
J-A few days, two digits, if less than two digits do not fill 0; such as: "1" to "31"
L-Days of the week, full name in English; such as: "Friday"
M-month, two digits, if less than two digits in front of the 0; such as: "01" to "12"
N-month, two digits, if less than two digits will not fill 0; such as: "1" to "12"
M-month, three English letters; such as: "The"
S-seconds; such as: "00" to "59"
S-word tail plus English ordinal number, two English letters; such as: "th", "nd"
T-Specifies the number of days of the 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 the year; such as: "0" to "365"