Modify the date. timezone parameter in php. ini:
[Date]
; Defines the default timezone used by the date functions
; Date. timezone =
It is disabled by default. You only need to remove the comment and change it
[Date]
; Defines the default timezone used by the date functions
Date. timezone = PRC
PRC is the People's Republic of China "!
For other options, refer to the php manual.
However, the above Asia region missed our capital, Beijing. I don't know if foreigners intentionally did it!
If you do not have the permission to modify php. ini, you only need to call date_default_timezone_set ('
Prc!
You can also call date_default_timezone_get () to view the current time zone settings!
For XXX, the available values for large regions are:
Asia/Chongqing, Asia/Shanghai, Asia/Urumqi)
Hong Kong and Taiwan regions available: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (in sequence: Macao, Hong Kong, and Taipei)
Region: date. timezone = "Asia // Taipei"
Singapore: Asia/Singapore
Solution to eight hours of time difference in PHP5
After installing php5, I accidentally saw someone on the Forum saying that php5.1.2 showed a total of eight hours,
<? Php
Echo date ("Y-m-d H: I: s ");
?>
The test result is 8 hours different.
Later, after finding information on the Forum, we finally solved the problem. In php5 and later versions, we had to output local time (limited to China)
, You can write the code like this:
<? Php
Date_default_timezone_set ('Asia/Shanghai ');
Echo date ('Y-m-d H: I: s ');
?>
You can also write the code as follows:
<? Php
Date_default_timezone_set ('Asia/chongqing ');
Echo date ('Y-m-d H: I: s ');
?>
In this way, the problem of time difference of eight hours is solved !!~~~