将时间戳转换为“ yy/mm/dd”与JS

发布于 2025-01-29 13:46:02 字数 242 浏览 5 评论 0 原文

我需要将我的“ 80814.899999999851”时间戳转换为yy/mm/dd字符串。 我首先这样做:

var prova = info.originalevent.timestamp; //此路径导致:80814.89999999851

var prova2 = new Date(Prova);

现在,我将其作为日期时间(如果我没记错的话),但是我不知道如何仅保留年/月/天,然后将其转换为字符串。 有人可以帮我吗?

I need to convert my "80814.89999999851" timestamp to a YY/MM/DD string.
I started by doing this:

var prova = info.originalEvent.timeStamp; //this path lead to: 80814.89999999851

var prova2 = new Date(prova);

Now I have it as a datetime (if i'm not mistaken) but i don't know how to keep just the year/month/day and then convert it to a string.
Can someone help me?

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

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

发布评论

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

评论(1

稚气少女 2025-02-05 13:46:02

自Unix Epoch以来,此时间戳不是秒,它是自 TimeOrigin (很可能是加载页面以来的时间)以来的秒,才能将其转换为迄今为止,您需要首先获得 Timeorigin 。看看这个问题:知道事件的时间来源的时间来源

This timestamp is not seconds since unix epoch, its seconds since timeOrigin (most likely time since page was loaded), to convert it to date you need to obtain timeOrigin first. Take a look at this question: Knowing the time origin of event's timestamp.

https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp

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