How PHP gets the day of the week

Source: Internet
Author: User

PHP day of the week to get the code:
Date ("l"); // data can be used to obtain the week in English, such as Sunday.
Date ("w"); // you can obtain the number of weeks, for example, 123. Note that 0 is Sunday.

Get Chinese day of the week:
$ Weekarray = array ("day", "one", "two", "three", "four", "five", "Six"); // define an array first
Echo "Week". $ weekarray [date ("w")];

Obtain 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 very powerful, he is fully qualified for all such work. I have attached a table in the manual for convenient reference at any time.
1. a-"am" or "pm"
2. A-"AM" or "PM"
3. d-a few days, two digits. If there are less than two digits, fill in the first zero. For example: "01" to "31"
4. D-the day of the week, with three English letters, for example, "Fri"
5. F-month, full English name; for example: "January"
6. h-12 hours; for example, "01" to "12"
7. H-24 hours; for example: "00" to "23"
8. hours in the g-12 hour format, less than two do not fill in zero; for example: "1" to 12"
9. hours in the G-24 hour system, less than two do not fill in zero; for example: "0" to "23"
10. I-minutes; for example: "00" to "59"
11. j-a few days, two digits. If less than two digits are left blank, for example, "1" to "31"
12. l-the day of the week. Full name in English; for example, "Friday"
13. m-month, two digits. If there are less than two digits, add zero in front, for example, "01" to "12"
14. n-month, two digits. If less than two digits are left blank, for example, "1" to "12"
15. M-month, with three English letters, for example, "Jan"
16. s-second; for example: "00" to "59"
17. S-ending with an English sequence, two English letters, for example, "th", "nd"
18. t-specifies the number of days in a month, for example, "28" to "31"
19. U-total seconds
20. w-number of weeks, for example, "0" (Sunday) to "6" (Saturday)
21. Y-year, four digits, for example, "1999"
22. y-year, two digits, for example, "99"
23. z-the day of the year; for example, "0" to "365"

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.