所以我有 -
timezone = pytz.timezone('Asia/Kolkata')
one_time_stamp = '2017-06-01 05:30:00'
zoned_time_stamp = datetime.datetime.strptime(one_time_stamp, '%Y-%m-%d %H:%M:%S')
#This outputs 2017-06-01 05:30:00 which is fine.
print(zoned_time_stamp)
#notice timezone added
non_iso_zoned_ts = zoned_time_stamp.replace(microsecond=0, tzinfo=timezone)
# This outputs 2017-06-01 05:30:00 which is fine.
print(zoned_time_stamp)
iso_date = non_iso_zoned_ts.isoformat()
#This outputs 2017-06-01T05:30:00+05:53 which is incorrect. Ideally it should be 2017-06-01T05:30:00+05:30
print(iso_date)
现在我想知道为什么 isoformat 添加了 05:53 的偏移量,而亚洲/加尔各答时区是 +05:30。参考 - https://www.zeitverschiebung.net/en/timezone/asia--kolkata
慕田峪9158850
相关分类