If you are using a standalone server with permissions to modify the configuration file, setting the time zone can be done by modifying the Date.timezone property in PHP.ini. We can set the value of this property to one of \ "asia/shang\", \ "asia/chongqing\", \ "Etc/gmt-8\" or PRC, etc.
, and then the current time in the PHP script is Beijing time. The configuration file for modifying PHP is as follows:
1.date.timezone = etc/gmt-8
Set the default time zone in the configuration file to East 8 (Beijing time)
Add one more sentence to the PHP program you need:
| The code is as follows |
Copy Code |
|
Date_default_timezone_set (' PRC '); |
The test can be written like this:
| The code is as follows |
Copy Code |
|
Date_default_timezone_set (' PRC ');
?> |
Whether PHP is installed under Windows or Linux, its default installation time zone is 8 hours from China
You can also open the php.ini file in the server, find the Date.timezone, remove the preceding semicolon, change to date.timezone= PRC (If you cannot find the Date.timezone in php.ini, you can add a line directly DATE.TIMEZONE=PRC also).
Set the time zone in your code
| 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 ');//Where PRC is the "People's Republic of China" |
http://www.bkjia.com/PHPjc/632154.html www.bkjia.com true http://www.bkjia.com/PHPjc/632154.html techarticle If you are using a standalone server with permissions to modify the configuration file, setting the time zone can be done by modifying the Date.timezone property in PHP.ini. We can set the value of this property to ...