如何从Unix时间戳(语言不可知论)中获取年度,每日,秒和毫秒?

发布于 2025-01-21 14:27:54 字数 569 浏览 1 评论 0 原文

不寻找特定环境的日期方法,例如 this 用于计算这些日期字段,但是您如何将它们与unix时间戳(例如现在)隔离,是 1650045773120 ?从1970年1月1日起,它是在UTC的毫秒内,但我不确定如何进行转换以隔离这些值。如果有源代码的链接已经显示了该实现,那也可以起作用。

const start = new Date(0)
const now = Date.now()

这似乎是相当复杂的,因此想知道Jodatime或JavaScript date 如何在引擎盖下实现此操作,也许是源代码所在的位置。除非您知道如何直接做。

Not looking for the environment-specific date methods like this for calculating these date fields, but how do you isolate them from a Unix timestamp such as now, which was 1650045773120? It is in milliseconds from Jan 1 1970 UTC, but I'm not sure how to do the conversion to isolate these values. If there are links to source code which already show the implementation, that would work too.

const start = new Date(0)
const now = Date.now()

This seems like it will be fairly complex, so wondering how JodaTime or the JavaScript Date implement this under the hood, and perhaps where the source code is. Unless you know how to do it directly.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文