Home >Backend Development >PHP Problem >How to set time zone in php.ini
Method: First, open the "php.ini" configuration file in the PHP installation directory, search for the "date.timezon" item; then remove the ";" in front of ";date.timezone=", and Just fill in the corresponding time zone identifier after "=". For example, "PRC" can set the Chinese time zone.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Set the time zone in the php ini configuration file
The PHP configuration file is the php.ini file in the PHP installation directory. Find and open it. Then search for date.timezone
in the file, we will see a piece of information as shown below:
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone =
where;date.timezone =
in front of ;
has the same function as //
in PHP. They both mean comments. Here we need to remove this ;
and add the in this sentence. =
Fill in the corresponding time zone identifier after, as shown below:
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Asia/Shangha
There are many time zone identifiers. Here are some commonly used time zone identifiers and their meanings:
Asia/Shanghai —— Shanghai
Asia/Chongqing —— Chongqing
Asia/Urumqi —— Urumqi
Asia/Hong_Kong —— Hong Kong
Asia/Macao —— Macao
Asia/Taipei — — Taipei
Asia/Singapore — Singapore
PRC — China Time Zone
Tip: If we are in China, we set the time zone to "Asia/Shanghai
or PRC
" are acceptable. Remember to restart the server after successful setting!
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set time zone in php.ini. For more information, please follow other related articles on the PHP Chinese website!