Detailed explanation of getting the day of the week in PHP_PHP tutorial

WBOY
Release: 2016-07-13 17:41:30
Original
833 people have browsed it

PHP day of the week acquisition code:
date("l"); //Data can get the English day of the week such as Sunday
date("w"); //This can get the numeric day of the week such as 123, note that 0 is Sunday

Get the Chinese day of the week:
$weekarray=array("日","一","二","三","四","五","六"); / /First define an array
echo "week".$weekarray[date("w")];

Get the specified date:
$weekarray=array("日","一" ,"two","three","four","five","six");
echo "week".$weekarray[date("w","2011-11-11")];

Because the date function is very powerful, it can handle all such tasks. I have attached a table in the manual for easy reference at any time
1. a - "am" or "pm"
2. A - "AM" or "PM"
3. d - Day, two digits, if there are less than two digits, add zero in front; such as: "01" to "31"
4. D - Day of the week Number, three English letters; such as: "Fri"
5. F - month, full English name; such as: "January"
6. h - hour in 12-hour format; such as: "01" to" 12"
7. H - hour in 24-hour format; such as: "00" to "23"
8. g - hour in 12-hour format, no zeros are added for less than two digits; such as: "1" to 12"
9. G - hour in 24-hour format, zeros are not added if there are less than two digits; such as: "0" to "23"
10. i - minute; such as: "00" to "59"
11. j - day, two digits, if there are less than two digits, do not add zero; such as: "1" to "31"
12. l - day of the week, full English name; such as: "Friday"
13. m - month, two digits, if there are less than two digits, add zeros in front; such as: "01" to "12"
14. n - month, two digits, if there are less than two digits, no Fill in zeros; such as: "1" to "12"
15. M - month, three English letters; such as: "Jan"
16. s - seconds; such as: "00" to "59"
17. S - add an English ordinal number at the end of the word, two English letters; such as: "th", "nd"
18. t - specify the number of days in the month; such as: "28" to "31"
19. U - Total seconds
20. w - Numeric day of the week, such as: "0" (Sunday) to "6" (Saturday)
21. Y - Year, four digits; such as: "1999"
22. y - year, two digits; such as: "99"
23. z - day of the year; such as: "0" to "365"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486124.htmlTechArticlePHP day of the week get code: date("l"); //data can get the English day of the week such as Sunday date("w"); //This can get the numerical day of the week, such as 123. Note that 0 is Sunday to get the Chinese day of the week...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!