[英]How to set half hour and 45-minute time zones without worrying about DST changes in Linux?
Currently I am setting time zone GMT+5 on my Linux CentOS 7 machine by linking /etc/localtime
to /usr/share/zoneinfo/Etc/GMT-5.
目前,我通过将
/etc/localtime
链接到/usr/share/zoneinfo/Etc/GMT-5.
在我的 Linux CentOS 7 机器上设置时区 GMT+ /usr/share/zoneinfo/Etc/GMT-5.
I want to create a zone info file for example /usr/share/zoneinfo/Etc/GMT-5:30
that enables me to set the current timezone to GMT+5:30 without having to worry about DST changes .我想创建一个区域信息文件,例如
/usr/share/zoneinfo/Etc/GMT-5:30
使我能够将当前时区设置为 GMT+5:30而不必担心 DST 更改。
I am aware that I could link /etc/localtime
to /usr/share/zoneinfo/Asia/Kolkata
for example but then I will have to worry about DST changes even if it may not be implemented in the mean time.我知道我可以将
/etc/localtime
链接到/usr/share/zoneinfo/Asia/Kolkata
例如,但是我将不得不担心 DST 更改,即使它可能不会同时实施。
Also I am aware of TZ=GMT+5:30; export $TZ
我也知道
TZ=GMT+5:30; export $TZ
TZ=GMT+5:30; export $TZ
but I am worried that this approach backfire for some reason in the future. TZ=GMT+5:30; export $TZ
但我担心这种方法将来会因某种原因适得其反。
If you don't want to use $TZ variable, you may want to create your own timezone file.如果您不想使用 $TZ 变量,您可能需要创建自己的时区文件。
You need create a text file (say MyZone.zic) with您需要创建一个文本文件(比如 MyZone.zic)
Zone MyZone 5:30 - GMT-5:30
then run然后运行
zic -d <desired_folder> MyZone.zic
then link compiled file to /etc/localtime然后将编译后的文件链接到 /etc/localtime
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.