How to modify php time with centos
This article mainly explains "how to modify php time with centos". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to modify php time with centos.
Centos modifies php time: 1, modify hardware time zone; 2, modify system time zone; 3, modify php.ini time zone setting; 4, synchronize time through crontab.
This article operating environment: centos6.5 system, PHP7.1 version, DELL G3 computer
How does centos modify php time?
Modify linux time zone time and php time zone
Problem: the customer's US server time is incorrect.
The first step is to modify the hardware time zone.
Vim / etc/sysconfig/clock
Comment ZONE= "America/New_York" and add an extra line ZONE= "Asia/Shanghai"
Second, modify the system time zone
Cp / etc/localtime / etc/localtime.bakrm-rf / etc/localtimeln-svf / usr/share/zoneinfo/Asia/Shanghai / etc/localtimeyum install ntpdate-yntpdate 0.centos.pool.ntp.orgdateclock-w # write the current Linux time to BIOS! Clock-r # check the time in BIOS
The third step is to modify the time zone setting of php.ini
Date.timezone = PRC
Step 4, write a crontab to synchronize the time (in special cases, add this)
# Ansible: Time synchronization00 01 * / usr/sbin/ntpdate 0.centos.pool.ntp.org > / dev/null
How to set the synchronization time for each boot
Vim / etc/rc.localusr/sbin/ntpdate 0.centos.pool.ntp.org > / dev/null
The above is to set the time zone and time of centos6.5, and the following is that of centos7
Yum-y install ntpsystemctl enable ntpdntpdate-u cn.pool.ntp.orgsystemctl start ntpd# setting time zone timedatectl set-timezone Asia/Shanghai so far, I believe you have a deeper understanding of "how to modify php time with centos". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!