PHP obtains the system time

Source: Internet
Author: User

PHP obtains the system time

 

<? PHP
Echo date ("Y-m-d h: I: s ");
?>

<? PHP

Date_default_timezone_set ('Asia/Chongqing '); // the system time difference is 8 hours.
$ Now = getdate (Time ());
$ Cur_wday = $ now ['wday'];
$ Date = date ("Y-m-d h: I: S $ cweekday [$ cur_wday]");
Echo $ date;

?>

 

Meanings of specific letters:

A-"am" or "PM"

A-"am" or "PM"

B-swatch Internet time

D-the day of the month, which has two digits leading to zero, for example, "01" to "31"

D-the day of the week. The text represents three letters, for example, "fri"

F-month, complete text format, such as "January"

G-hour, 12-hour format, no leading zero, for example, "1" to "12"

G-hour, 24-hour format, no leading zero, for example, "0" to "23"

H-hour, 12-hour format, for example, "01" to "12"

H-hour, in 24-hour format, for example, "00" to "23"

I-minutes, for example, "00" to "59"

I (an uppercase letter of "I")-if it is "1", otherwise it is "0"

J-the day in the month, without leading zero, for example, "1" to "31"

L (lowercase letter of "L")-day of the week, complete text format, such as "Friday"

L-Boolean value indicates whether it is a leap year, for example, "0" or "1"

M-month, for example, "01" to "12"

M-month, represented in text, with three letters, for example, "Jan"

N-month, no leading zero, for example, "1" to "12"

O-hours different from Greenwich mean time, for example, "+ 0200"

Date in the format of R-RFC 822, such as "Thu, 21 Dec 2000 16:01:07 + 0200" (added in PHP 4.0.4)

S-seconds, for example, "00" to "59"

S-English suffix after the number of days per month, 2 characters, such as "St", "nd", "RD" or "th"

T-the number of days of a given month, for example, "28" to "31"

T-the time zone in which the local machine is located, for example, "est" or "MDT" ([note] the full text format is in windows, for example, "Eastern Standard Time ", the Chinese version displays "China Standard Time ".)

U-number of seconds since UNIX epoch (January 1 1970 00:00:00 GMT)

The day of the week, represented by a number, for example, "0" (Sunday) to "6" (Saturday)

Week of the Year in W-ISO-8601 format, starting from Monday each week (newly added in PHP 4.1.0)

Y-year, four digits, for example, "1999"

Y-annual fee, two digits, for example, "99"

The day of the Z-year, for example, "0" to "365"

The number of seconds of the Z-Time Difference offset (for example, "-43200" to "43200 "). The Time Zone offset to 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.