[英]Datetime's timestamp function not matching expected UNIX time
The following 下列
import datetime as dt
dt.datetime(2019, 7, 21).timestamp()
returns 退货
1563663600.0 .
1563663600.0。
However, if I look on https://www.unixtimeconverter.io/list/2019/july , then I see that the expected Unix time for this date is 1563667200. 但是,如果我查看https://www.unixtimeconverter.io/list/2019/july ,那么我看到该日期的预期Unix时间是1563667200。
Why the discrepancy? 为什么会有差异?
datetime
doesn't assume UTC by default, so you need to specify it. datetime
默认情况下不采用UTC,因此您需要指定它。
dt.datetime(2019, 7, 21, tzinfo=dt.timezone.utc).timestamp()
1563667200
1563667200
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.