如何更正时区 [英] How to Correct Timezone

查看:46
本文介绍了如何更正时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 vagrant 服务器的时区设置为亚洲/东京.但是,尽管我在 php.ini 中进行了更改并重新启动了 httpd,但它并没有返回正确的时间.时间比正确时间晚了 9 小时.当我更改欧洲/贝林时区时,我看到时间发生了变化,但它也没有返回正确的时间.

这是我的php代码

echo('

');var_dump(date("Y/m/d G:i:s"));echo('</pre>');出口;

php.ini

date.timezone = 亚洲/东京

有什么建议吗?

解决方案

我终于找到了出路.上面的代码不工作的原因是我的系统时钟不对,所以我执行了下面的命令.

首先,我安装了ntp.

sudo yum -y install ntp

其次,我从 ntp 得到了正确的时间.

sudo ntpdate ntp.nict.jp

就是这样.感谢您的建议!

一个有用的链接:http://pyoonn.hatenablog.com/entry/2015/01/06/121925

I set my vagrant server's timezone to Asia/Tokyo. However, though I made change in php.ini and restarted httpd, it doesn't return the correct time. The time is 9 hours late from correct time. When I change the time zone Europe/Berin, I see the time changes but it also doesn't return correct time.

Here is my php code

echo('<pre>');
var_dump(date("Y/m/d G:i:s"));
echo('</pre>');
exit;

php.ini

date.timezone = Asia/Tokyo

Are there any suggestions?

解决方案

I finally found the way out. The reason the code above didn't work was that my system clock was wrong, so I executed the command bellow.

First, I installed ntp.

sudo yum -y install ntp

Second, I got the correct time from ntp.

sudo ntpdate ntp.nict.jp

That's it. Thanks for suggestions!

A helpful link: http://pyoonn.hatenablog.com/entry/2015/01/06/121925

这篇关于如何更正时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆