date - Linux夏令时是怎么调整的?
天蓬老师
天蓬老师 2017-04-17 13:44:08
[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
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(1)
PHPz

后来发现,在date命令中设置时间的时候,可以加入时区参数:date -s "2015-10-25 01:00:00 EST"

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号