Example code for PHP to get system time

Source: Internet
Author: User
Tags echo date
    1. Method 1

    2. echo Date ("y-m-d h:i:s");

    3. Method 2

    4. Date_default_timezone_set (' asia/chongqing '); System time Difference 8-hour problem
    5. $now = getdate (Time ());
    6. $cur _wday= $now [' wday '];
    7. $date = Date ("y-m-d h:i:s $cweekday [$cur _wday]");
    8. Echo $date;
    9. by bbs.it-home.org
    10. ?>
Copy Code

The meaning of the letter in the date function: A-"AM" or "PM" A-"AM" or "PM" B-swatch Internet time D-the day ordinal of the month with a leading zero 2-digit number, for example "" "to" D "-the first of the week Day, text representation, 3 letters, such as "Fri" F-month, full text format, such as "January" G-hour, 12-hour format, no leading zeros, such as "1" to "three" G-hour, 24-hour format, no leading zeros, e.g. "0" to "H" -Hours, 12-hour format, such as "01" to "a" H-hour, 24-hour format, such as "00" to "" I-minute, such as "00" to "I" (uppercase letters of "I")-if daylight saving time is "1", otherwise "0" J-month The day of the week, there is no leading zeros, such as "1" to "+" L (lowercase letters of "L")-the days of the day, the full text format, such as "Friday" L-Boolean indicates whether it is a leap year, such as "0" or "1" m-month, for example "" to "M- month, text representation, 3 letters, such as "Jan" N-month, no leading zeros, such as "1" to "O"-hours of difference from Greenwich Mean time, such as "+0200" R-RFC 822 format date, for example "Thu, Dec 2000 16:0 1:07 +0200 "(New in PHP 4.0.4) s-seconds, e.g." 00 "to" s "-English suffix after the number of days per month, 2 characters such as" St "," nd "," rd "or" th "T-the number of days for a given month, e.g." 28 "to" 3 1 "T-natively is in a time zone, such as" EST "or" MDT "(" Translator note "is in full text format under Windows, such as" Eastern Standard Time ", Chinese version will show" Chinese standards ".) U-The number of seconds since the beginning of the Unix era (January 1 1970 00:00:00 GMT) W-the Day of the week, numbers indicate, for example, "0" (Sunday) to "6" (Saturday) the week of the w-iso-8601 format year, weekly Starting from Monday (PHP 4.1.0 New) y-year, 4 digits, e.g. "1999" Y-Annual fee, 2 digits, such as the number of seconds for the "Z-offset" (for example, "43200" to "43200"). The time zone offset in the west of UTC is always negative, and the time zone offset to the east of UTC is always positive.

  • 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.