PHP Gets the code for the time and day of the week

Source: Internet
Author: User
    1. /**
    2. * PHP Time Date function application
    3. * Edit bbs.it-home.org
    4. */
    5. echo "Today:". Date ("y-m-d"). "
      ";
    6. echo "Yesterday:". Date ("Y-m-d", Strtotime ("-1 Day")), "
      ";
    7. echo "Tomorrow:". Date ("Y-m-d", Strtotime ("+1 Day")). "
      ";
    8. echo "One week later:". Date ("Y-m-d", Strtotime ("+1 Week")). "
      ";
    9. 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")). "
      ";
    10. echo "Next week Four:". Date ("Y-m-d", Strtotime ("next Thursday")). "
      ";
    11. echo "Previous Monday:". Date ("Y-m-d", Strtotime ("Last Monday")). "
      ";
    12. echo "One months ago:". Date ("Y-m-d", Strtotime ("Last month"). "
      ";
    13. echo "One months later:". Date ("Y-m-d", Strtotime ("+1 Month")). "
      ";
    14. echo "Ten years later:". Date ("Y-m-d", Strtotime ("+10 Year")). "
      ";
    15. ?>
Copy Code

The function of the Strtotime () function is to parse the datetime description into the Unix timestamp int strtotime (string time [, int now])

PHP Week:

    1. Date ("L");
    2. Data can be obtained in English for weeks such as Sunday
    3. Date ("W");
    4. This can get the numbers for weeks like 123, note that 0 is Sunday
Copy Code

Get Chinese Week:

    1. $weekarray =array ("Day", "one", "two", "three", "four", "five", "six");
    2. echo "Week". $weekarray [Date ("W")];
Copy Code

Get specified date:

    1. $weekarray =array ("Day", "one", "two", "three", "four", "five", "six");
    2. echo "Week". $weekarray [Date ("W", "2011-11-11")];
Copy Code

Attached, date function parameter control. A-"AM" or "PM" A-"AM" or "PM" D-a few days, two digits, if less than two digits before 0; such as: "01" to "D"-Day of the week, three letters of English; such as: "Fri" F-month, English full name; such as: "January" h-12 hours of the hour system; such as: "01" to "a" H-24 hours of the hour system; such as: "00" to "g-12" hours of the hour system, less than two does not fill 0; such as: "1" to three "G-24 hours of the hour, less than two does not fill 0; such as: "0" to "the" I-minute; such as: "00" to "the" J-a few days, two digits, if less than two bits do not fill 0; such as: "1" to "~" 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 "three" N-month, two digits, if less than two will not fill 0; such as: "1" to "ten" M-month, three English letters; such as: "Jan" s-second; such as: "00" to "the" S-the end of the English ordinal, two English letters; such as: "th", "nd" T-Specify the number of days of the month; e.g. "28" to "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: "" "Z-the first day of the year; such as: "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.