Two ways to set the time zone in PHP

Source: Internet
Author: User

After php5, you have to set the time zone yourself, either modify the settings of the php.ini or modify it in your code.

Setting the time zone in php.ini

Date.timezone = PRC

Set the time zone in your code

1 date_default_timezone_set (' Asia/shanghai ');//' Asia/shanghai ' Asia/Shanghai

2 Date_default_timezone_set (' asia/chongqing ');//Where asia/chongqing ' is ' Asia/Chongqing '

3 Date_default_timezone_set (' PRC ');//Where PRC is the "People's Republic of China"

4i ni_set (' Date.timezone ', ' etc/gmt-8 ');

5 ini_set (' Date.timezone ', ' PRC ');

6 Ini_set (' Date.timezone ', ' Asia/shanghai ');

7 ini_set (' Date.timezone ', ' asia/chongqing ');

The above seven ways, any one can meet our needs.

When the system is initialized, add

ini_set (' Date.timezone ', ' Asia/shanghai ');  or Date_default_timezone_set ("PRC"); will resolve the time zone difference 8

Hours of problems.

Source

Http://sjolzy.cn/php-set-the-time-zone-of-the-two-methods.html

Two ways to set the time zone in PHP

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.