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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:14:40  来源:igfitidea点击:

Timezone in date?

linuxdatetimezonelocaltime

提问by nitin_cherian

From where does the datecommand in Linux get the timezoneinformation? I cannot see /etc/localtimefile and /usr/share/zoneinfodirecory in my system. Still when i execute the datecommand i get the following output

dateLinux中的命令从哪里获取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 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
#