At the beginning of php5.1.0, the date. timezone option is added to php. ini, which is disabled by default. The display time is Greenwich Mean Time, which is exactly eight hours different from that in Beijing.
Solution:
Modify the php. Ini file and search for the file; date. timezone =. Remove the semicolon before and add the time zone after "=.
For example:
Asia/Chongqing (Chongqing ),
Asia/Shanghai (Shanghai ),
Asia/Urumqi (Urumqi ),
Asia/Macao (Macao ),
Asia/Hong_Kong (Hong Kong ),
Asia/Taipei (Taipei ),
PRC China
For example
The code is as follows: |
Copy code |
Date. timezone = PRC |
You can also add at the top of the php program page
The code is as follows: |
Copy code |
<? Php Date_default_timezone_set ('Asia/Chongqing '); Echo date ('Y-m-d H: I: s '); ?> |
Related recommendations
Multiple solutions for 8 hours of time difference in php
Http://www.111cn.net/phper/31/42398.htm
Php date difference 8 small time solution
Http://www.111cn.net/phper/31/37224.htm
Php obtains server time (solving the eight-hour gap)
Http://www.111cn.net/phper/31/34041.htm