Date_default_timezone_set set China time zone _ PHP Tutorial

Source: Internet
Author: User
Date_default_timezone_set specifies the China time zone. The following describes how to set the China time zone in date_default_timezone_set. if you need a simple function, refer to it. Date_default_timezone_set is used in a script. The following describes how to set date_default_timezone_set to the Chinese time zone. if you need this function, refer to it.

Date_default_timezone_set-sets the default time zone used for all date and time functions in a script.


Bool date_default_timezone_set (string $ timezone_identifier)

Parameter description
Timezone is required. Time zone identifier, such as "UTC" or "Europe/Paris ".

Note: Since PHP 5.1.0 (this version of the DATETIME function has been rewritten), if the time zone does not comply with the rules, every call to the DATETIME function will generate an E_NOTICE-level error message, if you use system settings or TZ environment variables, information at the E_STRICT level will also be generated.

Set China time zone

The code is as follows:
Date_default_timezone_set ('Asia/Shanghai'); // 'Asia/Shanghai' Asia/Shanghai
Date_default_timezone_set ('Asia/Chongqing '); // The value of Asia/Chongqing is "Asia/Chongqing"
Date_default_timezone_set ('prc'); // PRC is "People's Republic of China"

Note: Any of the above three methods can meet our needs.

Bytes. Date_default_timezone_set is used in a script...

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