Home >Backend Development >PHP Tutorial >Summary of solutions to the 8-hour time difference in PHP_PHP tutorial

Summary of solutions to the 8-hour time difference in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:41:461273browse

It turns out that starting from php5.1.0, the date.timezone option has been added to php.ini. It is turned off by default

, which means that the time displayed (no matter what php command is used) is Greenwich Mean Time

There is a difference of exactly 8 hours from our time (Beijing time). There are 3 methods below to restore the normal time.

1. The simplest way is not to use php5.1 or above.

2. If you must use it and cannot modify php.ini, you need to initialize the time statement. Add date_default_timezone_set (XXX);

3 to
, once and for all, only php.ini can be modified. Open php.ini and search for date.timezone. Remove the semicolon in front
= and add XXX after it. Restart the http service (such as apache2 or iis, etc.)


Regarding XXX, the values ​​​​available in mainland China Are: Asia/Chongqing, Asia/Shanghai, Asia/Urumqi (in order Chongqing, Shanghai, Urumqi)
Available in Hong Kong and Taiwan: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (in order Macau, Hong Kong, Taipei)
And Singapore: Asia/Singapore
Foreigners seem to have missed Beijing
Other available values ​​are: Etc/GMT-8, Singapore, Hongkong, PRC
What is PRC? PRC is the People's Republic of China -_-
The above are the regions under GMT-8 that I compiled from the official php manual file. There may be some omissions.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321094.htmlTechArticleIt turns out that starting from php5.1.0, the date.timezone option was added to php.ini, which is turned off by default. That is to say, the time displayed (no matter what php command is used) is Greenwich Mean Time...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn