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!! ~~~