我正在尝试将此UNIX时间戳1491613677888转换为可读日期。 在这里找到(stackoverflow)python脚本:
import datetime
print(
datetime.datetime.fromtimestamp(
int("1284101485")
).strftime('%Y-%m-%d %H:%M:%S')
)
但是当我把我的时间戳放在那里时,我遇到了这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
现在我发现我使用的时间戳比应有的多了3个字符。 我在这个链接上进行了检查: http://www.unixtimestamp.com/index.php
并且看到它从中获取时间。 我该如何在Python中实现这个功能呢? (我正在使用Python 3.4版本)
1491613677
是 2017-04-08T01:07:57+00:00,这可能是你想要的。有了它,你的代码可以完美运行。 - Thierry Lathuilleint("1284101485888")
时,会收到ValueError: year is out of range错误;而在Python 3.6上则会得到42661-07-22 17:11:28的结果。 - cdarke