CentOS Date Time difference 8 hours how to solve

Source: Internet
Author: User
Tags echo date centos

1, Vi/etc/sysconfig/clock #编辑文件
Zone= "Asia/shanghai"
Utc=false #设置为false, hardware clock is not consistent with UTC time
Arc=false

2, Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime #linux的时区设置为上海

3, Ntpdate asia.pool.ntp.org #对准时间, you need to first install NTP server yum install NTP

4,/sbin/hwclock--SYSTOHC #设置硬件时间和系统时间一致并校准

add that if you are PHP running in CentOS found relevant 8 hours we can solve the problem as follows

Setting the time zone in php.ini

Date.timezone = PRC

If you do not have php.ini Modify permissions

<?php
Date_default_timezone_set (' asia/chongqing ');
echo Date (' y-m-d h:i:s ');
?>

Can

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.