开发者社区> 问答> 正文

Linux夏令时是怎么调整的?

以法国巴黎为例:

root@121 zoneinfo]# ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
[root@121 zoneinfo]# date
2015年 10月 13日 星期二 03:45:09 CEST
[root@121 zoneinfo]# date -R
Tue, 13 Oct 2015 03:45:31 +0200
[root@121 zoneinfo]# zdump -v /etc/localtime | grep 2015
/etc/localtime  Sun Mar 29 00:59:59 2015 UTC = Sun Mar 29 01:59:59 2015 CET isdst=0 gmtoff=3600
/etc/localtime  Sun Mar 29 01:00:00 2015 UTC = Sun Mar 29 03:00:00 2015 CEST isdst=1 gmtoff=7200
/etc/localtime  Sun Oct 25 00:59:59 2015 UTC = Sun Oct 25 02:59:59 2015 CEST isdst=1 gmtoff=7200
/etc/localtime  Sun Oct 25 01:00:00 2015 UTC = Sun Oct 25 02:00:00 2015 CET isdst=0 gmtoff=3600
[root@121 zoneinfo]# date -s "2015-10-25 02:59:50"
2015年 10月 25日 星期日 02:59:50 CET
[root@121 zoneinfo]# date -R
Tue, 13 Oct 2015 03:47:16 +0200
[root@121 zoneinfo]# date
2015年 10月 13日 星期二 03:58:32 CEST
从dump的信息可以看出,当巴黎时间到“2015-10-25 02:59:59”的时候,应该跳出夏令时。即从CEST时区调整至CET时区,时间回调一个小时。
但在将时间调整到“2015-10-25 02:59:50”测试的时候,就已经切换到了CET时区。
但是纽约时间就是正常的:
[root@121 zoneinfo]# ll /etc/localtime
lrwxrwxrwx 1 root root 36 10月 12 21:59 /etc/localtime -> /usr/share/zoneinfo/America/New_York
[root@121 zoneinfo]# zdump -v /etc/localtime | grep 2015
/etc/localtime  Sun Mar  8 06:59:59 2015 UTC = Sun Mar  8 01:59:59 2015 EST isdst=0 gmtoff=-18000
/etc/localtime  Sun Mar  8 07:00:00 2015 UTC = Sun Mar  8 03:00:00 2015 EDT isdst=1 gmtoff=-14400
/etc/localtime  Sun Nov  1 05:59:59 2015 UTC = Sun Nov  1 01:59:59 2015 EDT isdst=1 gmtoff=-14400
/etc/localtime  Sun Nov  1 06:00:00 2015 UTC = Sun Nov  1 01:00:00 2015 EST isdst=0 gmtoff=-18000
[root@121 zoneinfo]# date -s "2015-11-01 01:59:50"
2015年 11月 01日 星期日 01:59:50 EDT
[root@121 zoneinfo]# date
2015年 11月 01日 星期日 01:00:07 EST

展开
收起
a123456678 2016-06-23 11:41:02 4590 0
1 条回答
写回答
取消 提交回答
  • 后来发现,在date命令中设置时间的时候,可以加入时区参数:date -s "2015-10-25 01:00:00 EST"

    2019-07-17 19:46:05
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Decian GNU/Linux安全合规之路 立即下载
从 Linux 系统内核层面来解决实际问题的实战经验 立即下载
Debian GNU/Linux 安全合规之路 立即下载