Method One, set the time zone on the PHP page
In the front of the page plus the following application is OK
Date_default_timezone_set usage is as follows
Date_default_timezone_set
(PHP 5 >= 5.1.0rc1)
Date_default_timezone_set--Sets the default time zone for all date-time functions in a script
Description
BOOL Date_default_timezone_set (String timezone_identifier)
Date_default_timezone_set () Sets the default time zone for all date-time functions.
Usage
| code is as follows |
copy code |
|
1 Date_ Default_timezone_set (' Asia/shanghai ');//' Asia/shanghai ' Asia/Shanghai
2 Date_default_timezone_set (' Asia/chongqing '), where asia/chongqing ' is "Asia/Chongqing"
3 date_default_timezone_set (' PRC '), where PRC is "People's Republic of China"
4 Ini_set (' Date.timezone ', ' etc/gmt-8 ');
5 ini_set (' Date.timezone ', ' PRC ');
6 ini_set (' Date.timezone ', ' Asia/shanghai ');
7 ini_set (' Date.timezone ', ' asia/chongqing '); |
asia/shanghai– Shanghai
asia/chongqing– Chongqing
asia/urumqi– Urumqi
asia/hong_kong– Hong Kong
asia/macao– Macau
asia/taipei– Taipei
asia/singapore– Singapore
If you have server admin privileges, we can set the time zone in php.ini
| The code is as follows |
Copy Code |
|
Date.timezone = PRC |
Remove the front semicolon and restart Apache
Some of the problems you might encounter
1.warning:strftime (): It isn't safe to rely on the system's timezone settings. You are are *required* to use the Date.timezone setting or the Date_default_timezone_set () function.
2.warning:date (): It isn't safe to rely on the system's timezone settings. You are are *required* to use the Date.timezone setting or the Date_default_timezone_set () function.
3.notice:date_default_timezone_set (): TimeZone ID ' Asia/shanghai ' is invalid
Solutions
| The code is as follows |
Copy Code |
|
Date_default_timezone_set (' Asia/shanghai ');//' Asia/shanghai ' Asia/Shanghai
Date_default_timezone_set (' asia/chongqing '), where asia/chongqing ' is "Asia/Chongqing"
Date_default_timezone_set (' PRC '), in which PRC is the "People's Republic of China" |