为什么python dateTime.timestamp(0)返回1am,而不是00:00

发布于 2025-02-04 07:08:30 字数 215 浏览 1 评论 0 原文

According to the definition of Unix time, it measures the number of seconds that have elapsed since 00:00 UTC on January 1st 1970. However, when I run datetime.fromtimestamp(0) using python 3.8, I get 1970-01-01 01:00:00. Why is it 1AM and not 00:00?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的故事 2025-02-11 07:08:30

时带!!!

尝试以下操作:

from datetime import *
print(datetime.fromtimestamp(0, timezone.utc))

这在UTC中获得了时期时间(+00:00)

Timezones!!!

Try this:

from datetime import *
print(datetime.fromtimestamp(0, timezone.utc))

This gets the epoch time in UTC (+00:00)

一指流沙 2025-02-11 07:08:30

引用

返回 local 与Posix Timestamp相对应的日期和时间,例如按时间返回。Time()。

(强调我

的计算机在CET上运行吗?

Quoting the documentation of datetime.fromtimestamp

Return the local date and time corresponding to the POSIX timestamp, such as is returned by time.time().

(Emphasis mine)

Is your computer running on CET?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文