Tanky WooRSS

关于虚拟机linux(gentoo)中时间不对的问题

07 Dec 2012
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

需要了解的几个术语:

GMT、UTC、CST、Hardware Clock、系统时间 等等,不解释~

因为在一次数据库存入当前时间的时候,发现系统时间不对,date看了一下,快了8个小时。

翻了下gentoo的文档,原来先需要把时区设置好。

系统有哪些时区可以在/usr/share/zoneinfo里面找

我找了一个shanghai的做ln -s到/etc/localtime

但是显示的时间还是不对,这是设计到Hardware Clock(硬件时钟)的问题了,打开/etc/conf.d/hwclock文件:

可以看到这些信息:

# Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as # Greenwich Mean Time).  If that clock is set to the local time, then # set CLOCK to "local".  Note that if you dual boot with Windows, then # you should set it to "local". clock="UTC"

按照提示,把clock改为"local",重启就可以了。

更多信息可以参考这篇文章:

http://blog.csdn.net/liyuyao001/article/details/7187271