Several methods for getting a week in PHP

Source: Internet
Author: User
PHP day of the week to get the code: 1 date (l); 2 // data to get the English week such as Sunday3date (w); 4 // this can get the number of weeks such as 123, note that 0 is the day of the Chinese Week obtained on Sunday: 1 $ weekarray = array (day, one, two, three, four, five, six); 2 // define an array 3echo week first. $ week

PHP day of the week to get the code:

1 date ("l ");

2 // you can obtain the week in English, such as Sunday.

3 date ("w ");

4 // you can obtain the number of weeks, for example, 123. Note that 0 is Sunday.

Get Chinese day of the week:

1 $ weekarray = array ("day", "one", "two", "three", "four", "five", "six ");

2 // define an array first

3 echo "week". $ weekarray [date ("w")];

Obtain the specified date:

1 $ weekarray = array ("day", "one", "two", "three", "four", "five", "six ");

2 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 GB-12 hour, less than two do not fill zero; for example: "1" to 12"

9G-24 hour, less than two do not fill 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 do not fill in zero; for example: "1" to "31"

12 l-the day of the week, full English name; for example: "Friday"

13 m-month, two digits. If there are less than two digits, fill in the first zero; 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-years, 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.