有没有办法通过指定日期来获得 UTC 时间戳? 我期望的是:
datetime(2008, 1, 1, 0, 0, 0, 0)
应该会导致
1199145600
创建初始日期时间对象意味着没有时区信息。如果查看 datetime.utcfrom 时间戳的文档,创建 UTC 时间戳意味着省略时区信息。所以我猜想,创建一个简单的 datetime 对象(就像我所做的那样)将导致一个 UTC 时间戳。然而:
then = datetime(2008, 1, 1, 0, 0, 0, 0)
datetime.utcfromtimestamp(float(then.strftime('%s')))
结果出来了
2007-12-31 23:00:00
在 datetime 对象中是否仍然存在任何隐藏的时区信息? 我做错了什么?