Linux 日期中的时区?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4396575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Timezone in date?
提问by nitin_cherian
From where does the date
command in Linux get the timezone
information?
I cannot see /etc/localtime
file and /usr/share/zoneinfo
direcory in my system. Still when i execute the date
command i get the following output
date
Linux中的命令从哪里获取timezone
信息?我在我的系统中看不到/etc/localtime
文件和/usr/share/zoneinfo
目录。仍然当我执行date
命令时,我得到以下输出
Thu Dec 9 16:28:18 UTC 2010
UTC 2010 年 12 月 9 日星期四 16:28:18
Kindly tell me from where does the command get the timezone information?
请告诉我命令从哪里获取时区信息?
Thanks, LinuxPenseur
谢谢,LinuxPenseur
回答by Thomas
From http://www.wikihow.com/Change-the-Timezone-in-Linux
来自http://www.wikihow.com/Change-the-Timezone-in-Linux
On mobile phones and other small devices that run Linux, the time zone is stored differently. It is written in /etc/TZ, in the format that is described, for instance, in [4]. Edit this file manually or use echo (for instance, echo GMT0BST > /etc/TZ to set the the timezone of the United Kingdom).
在运行 Linux 的手机和其他小型设备上,时区的存储方式不同。它写在 /etc/TZ 中,格式如[4] 中所述。手动编辑此文件或使用 echo(例如,echo GMT0BST > /etc/TZ 来设置英国的时区)。
From http://www.radisys.com/files/support_downloads/03245-02_MPCMM0001_MPCMM0002_CMM_Software_TPS.pdf
来自http://www.radisys.com/files/support_downloads/03245-02_MPCMM0001_MPCMM0002_CMM_Software_TPS.pdf
The CMM determines the offset to local timezone maintained in file /etc/cmm/TZ and automatically updates the time.
CMM 确定与文件 /etc/cmm/TZ 中维护的本地时区的偏移量并自动更新时间。
回答by Spyros
回答by sarnold
Don't forget that UTCis how standard Unix systems store the date/time in the real time clock. You have to jump through hoops using funny programs (see the hwclock(8)
manpage) if you dual-boot to Windows, which prefers the localtime to be stored in the CMOS real time clock.
不要忘记UTC是标准 Unix 系统在实时时钟中存储日期/时间的方式。hwclock(8)
如果您双引导到 Windows,则您必须使用有趣的程序(请参阅联机帮助页)跳过箍,它更喜欢将本地时间存储在 CMOS 实时时钟中。
So the date(1)
program is simply showing you the results of "I have no configured time zone":
所以该date(1)
程序只是向您展示“我没有配置时区”的结果:
# date -u
Thu Dec 9 10:40:54 UTC 2010
# TZ=UTC date
Thu Dec 9 10:40:57 UTC 2010
# TZ=PST8PDT date
Thu Dec 9 02:41:02 PST 2010
#