I have installed Windows 7 and centos6.0 on several system time issues for a while. There has always been a small problem, that is, the system time of the two is always different, with a difference of 8 hours, in linux, the system time is always eight hours earlier than that in windows, that is, when windows is a.m... the Windows 7 and centos 6.0 systems have been installed for some time. There has always been a small problem, that is, the system time of the two systems is always different, with a difference of 8 hours, in linux, the system time is always 8 hours earlier than in windows. that is to say, when windows is six o'clock P.M. in the morning, it is in linux. After I set the system time in windows correctly, the time in linux is incorrect. if I set the time in linux correctly, windows is incorrect. I think it is a small problem, and I don't care about it. Recently I was studying php. today I wrote a testing program for printing the system time. I found that the printing time is incorrect, which is 8 hours different from the currently displayed system time (note, I set up a php environment in windows), but the difference is that the time is 8 hours later than the windows system time, at this time, I recalled the problem in linux. So I decided to study this issue. I searched the internet for this problem and found that not only did I encounter it, but I got the following conclusion based on the explanations of the netizens. For the time inconsistency between centos and windows, it turns out that the system time is calculated differently. The computer has a BIOS time, that is, the CMOS time. windows uses the BIOS time as the system time, while centos uses the BIOS time as the UTC standard time by default, the system time is calculated based on the time zone settings. for example, if the current system time zone is set to Beijing (Zone 8 in the East ), then the system time will be added to the BIOS time for 8 hours, resulting in an error. At this time, if we set the system time in linux correctly, it will update the BIOS time (current time-8 hours) at the same time. The next time we start windows, in windows, the BIOS time is used as the system time. Speaking of this, we all know the solution, changing the time computing mode for windows or linux systems. I chose to modify the linux system time calculation method: shell> vim/etc/sysconfig/clock to change the file to the following format. ZONE = "Asia/Shanghai" # set the time zone utc = false # disable the coordinated world time (ARC) = false: wq! Save and exit shell> ntpdate pool.ntp.org # Time-aligned shell>/sbin/hwclock -- systohc # set the hardware time to be consistent with the system time and calibrate the system time to solve this problem. In addition, the problem in php is because it is neither in php. the time zone specified in ini is not configured in the code in the page header using date_default_timezone_set (). The UTC standard time is used by default, which is 8 hours later than the current system. In php. ini, you can set the time zone or use the function you just used to set the time zone.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service