How does PHP convert the time it gets to the GMT?

Source: Internet
Author: User
Tags echo date
How PHP converts the time it gets to the GMT

Starting with php5.10, the time zone setting is added to PHP, and the times shown in PHP are Greenwich Mean time, which results in a eight-hour problem for our users in China!
The related setting is to modify the Date.timezone parameter in php.ini:
[Date]
; Defines the default timezone used by the date functions
;d Ate.timezone =

The default is off, just remove the comment, you can
[Date]
; Defines the default timezone used by the date functions
Date.timezone = PRC

Where PRC is the "People's Republic"!
Other options refer to the PHP manual.
However, the above-mentioned Asian region has missed our capital Beijing, do not know that foreigners are not intentional!

If the php.ini permission is not modified, simply call the Date_default_timezone_set (' PRC ') when calling the time-date function!
You can also call Date_default_timezone_get () to view the current time zone settings!

For XXX, the values available in the mainland are:
Asia/chongqing, Asia/shanghai, Asia/urumqi (Chongqing, Shanghai, Ukraine)
Available in Hong Kong and Taiwan: Asia/macao, Asia/hong_kong, Asia/taipei (Macau, Hongkong, Taipei)
Taiwan area can be set as: Date.timezone = "Asia//taipei"
and Singapore: Asia/singapore


Eight-hour solution for time difference in PHP5


After installing the PHP5, in the forum inadvertently, on the forum to see someone said php5.1.2 time shows a whole less than 8 hours,
??? echo Date ("y-m-d h:i:s");
?>
As a result, the test itself was 8 hours apart.
??
?? Later after the forum to find information, the results finally resolved, in PHP5 and from the above version, to output local time (limited to China), you can write code:
?? Date_default_timezone_set (' Asia/shanghai ');
?? echo Date (' y-m-d h:i:s ');
?>

You can also write code like this:
?? Date_default_timezone_set (' asia/chongqing ');
?? echo Date (' y-m-d h:i:s ');
?>
??
This time difference eight hours the problem is solved!! ~~~

  • Related Article

    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.