Home > Article > Operation and Maintenance > How to set php time zone on linux server
Setting method: 1. Open the "/etc/sysconfig/clock" file and change the value of the "ZONE" item to "Asia/Shanghai"; 2. Execute the command to modify the system time zone; 3. Open "php .ini" file, change the value of the "date.timezone" item to "PRC".
The operating environment of this tutorial: CentOS 6.5 system, PHP version 7.1, Dell G3 computer.
Modify the linux time zone time and php time zone
The first step is to modify the hardware time zone.
vim /etc/sysconfig/clock
Comment ZONE="America/New_York"
and add one more lineZONE=" Asia/Shanghai"
The second step is to modify the system time zone
cp /etc/localtime /etc/localtime.bak rm -rf /etc/localtime ln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime yum install ntpdate -y ntpdate 0.centos.pool.ntp.org date clock -w #将目前 Linux 的时间写到 BIOS 里面去! clock -r #检查 BIOS 里面的时间
The third step is to modify the time zone setting of php.ini
date.timezone = PRC
After setting up, it is best to restart the system.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to set php time zone on linux server. For more information, please follow other related articles on the PHP Chinese website!