gpt4 book ai didi

python - 将日期时间戳转换为本地纪元日期时间

转载 作者:太空宇宙 更新时间:2023-11-03 14:30:18 25 4
gpt4 key购买 nike

假设这是我的日期时间戳列表:

[datetime.datetime(2017, 11, 17, 9, 33, 11), datetime.datetime(2017, 11, 17, 9, 33, 36), datetime.datetime(2017, 11, 17, 9, 33, 48)]

已经给出了很多将这些值转换为纪元的示例,但这些值是 GMT 格式的。我们如何将其转换为大纪元本地时间?

用更简单的话来说。考虑到给定的日期时间采用 GMT 格式,一般纪元转换会将给定日期转换为纪元。但给定的日期时间是本地时间!

最佳答案

>>> x = datetime.datetime(2017, 11, 17, 9, 33, 36)
>>> x.timestamp()
1510882416.0
>>> x.ctime()
'Fri Nov 17 09:33:36 2017'

关于python - 将日期时间戳转换为本地纪元日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47349237/

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