Epoch Timestamp和Unix时间之间的区别是什么?

发布于 2025-02-12 02:12:20 字数 845 浏览 3 评论 0原文

致电API,我需要以毫秒为单位指定时间。我使用Python 3中的DateTime转换为人类可读日期和时间。但是,在调试时,我会根据使用哪个网站转换的网站获得不同的结果,因此当时间戳(也许)错误时,我很难调试。 API不会将时间和日期结合在其谓词中,而是将两者使用毫​​秒。

让我们看日期谓词1656547200000

如果我转到 https://currentmillis.com 它说是6月30日。一切都很好。 如果我转到 https://www.epochconverter.com 它说是6月30日。一切都很好。

让我们看一下从12600000到26700000的时间谓词。 12600000,26700000

如果我转到 https://currentmillis.com 它说它是UTC(24H)03:30-07-07-07-07-07-07-07-07-07 :25 如果我转到 https://www.epochconverter.com 它说是UTC(24H)20:00-- 00:40

为什么结果不同?

Calling an API, I need to specify time in milliseconds. I use DateTime in Python 3 to convert from and to human readable dates and times. But when debugging, I get different results depending on what website I use to convert, so I'm having a hard time debugging when the timestamps are (maybe) wrong. The API doesn't combine time and date in their predicates, but uses milliseconds for both.

Let's look at the date predicate 1656547200000

If I go to https://currentmillis.com it says it's June 30th. All good.
If I go to https://www.epochconverter.com it says it's June 30th. All good.

Let's look at the time predicate from 12600000 to 26700000.
12600000, 26700000

If I go to https://currentmillis.com it says it's UTC (24h) 03:30 - 07:25
If I go to https://www.epochconverter.com it says it's UTC (24h) 20:00 - 00:40

Why that different results?

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

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

发布评论

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

评论(1

掩耳倾听 2025-02-19 02:12:20

从历史上看,Unix系统认为时间是时间单元(秒,毫里,纳米等),因为绝对起源即将被称为“时代”:1970年1月1日00:00:00:00 UTC。这是

因此,“ Unix时间”是该系统中的计算系统和“ Epoch Timestamps”是该系统的时间点。

现在,在我看来,您似乎正在使用时空时间戳。

对于您的“短”时间戳,12600000 ,由于时期的时间点与自时代以来的时间点不同于12600000 milliseconds 。这就是为什么您会看到它们解决一天中不同的时间,因为您的转换器正在以不同的方式解释它们。如果您在输出中加入了日期,那么您将看到两个时间点相隔六个月。

Historically, UNIX systems reckon time as temporal units (seconds, millis, nanos, etc.) elapsed since an absolute origin instant termed "the Epoch": January 1st, 1970 00:00:00 UTC. This is formally recognized in POSIX.

So "UNIX time" is that system of reckoning, and "Epoch timestamps" are points in time in that system.

Now, you appear to me to be conflating temporal units in your use of Epoch timestamps.

In the case of your "short" timestamp, 12600000 seconds since the Epoch is a different point in time than 12600000 milliseconds since the Epoch. That's why you see them resolve to different times of day, as your converters are interpreting them differently. If you'd included the date in your output, you'd have seen the two points in time are almost six months apart.

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