gpt4 book ai didi

python - 使用 pytz 的时间转换不准确

转载 作者:行者123 更新时间:2023-11-28 20:22:29 27 4
gpt4 key购买 nike

<分区>

我正在使用 '2014.2' 版本的 pytz。我正在使用以下过程将 Asia/Kuwait 时区(即本地时间)转换为 UTC 时间:

>>> from_date = "2014/05/06 17:07"
>>> from_date = dateutil.parser.parse(from_date)
>>> utc=timezone('UTC')
>>> from_date = from_date.replace(tzinfo=timezone('Asia/Kuwait')).astimezone(utc)
>>> from_date
datetime.datetime(2014, 5, 6, 13, 55, tzinfo=<UTC>)
>>> from_date.strftime("%b %d %Y %H:%M:%S" )
'May 06 2014 13:55:00'

实际的 UTC 时间是 May 06 2014 14:06:00 我在以下位置找到:http://www.worldtimeserver.com/current_time_in_UTC.aspx为什么 pytz 没有准确地转换为实际时间。如您所见,10-11 分钟之间存在时差。

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