gpt4 book ai didi

python - Python 中的时区转换

转载 作者:太空狗 更新时间:2023-10-29 22:13:27 25 4
gpt4 key购买 nike

我可能遗漏了一些关于时区的信息:

>>> import datetime, pytz
>>> date = datetime.datetime(2013,9,3,16,0, tzinfo=pytz.timezone("Europe/Paris"))
>>> date.astimezone(pytz.UTC)
datetime.datetime(2013, 9, 3, 15, 51, tzinfo=<UTC>)

我很期待

datetime.datetime(2013, 9, 3, 15, 00, tzinfo=<UTC>)

谁能解释一下这 51 分钟是从哪里来的?

谢谢,

让-菲利普

最佳答案

UTC 偏移量给出 (date.tzinfo.utcoffset(date)):

datetime.timedelta(0, 540)

这是 540 秒或 9 分钟。

在法国,1911 年 3 月 11 日切换到 UTC,时钟拨回 9 分 21 秒(source 1source 2):

Until 1911, Paris was 9 minutes and 21 seconds off UTC.

您还可以在此处 (Paris time in 1911) 查看时间从 3 月 11 日凌晨 12:01:00 到 3 月 10 日晚上 11:51:39。

关于python - Python 中的时区转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19931913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com