为什么我需要在JavaScript中将unix时间戳乘以1000? [英] Why do I need to multiply unix timestamps by 1000 in JavaScript?

查看:798
本文介绍了为什么我需要在JavaScript中将unix时间戳乘以1000?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信我必须在JavaScript中为每个Unix时间戳添加三个零才能获得正确的日期。你能告诉我为什么吗?从epoch与秒相比,它是否简单为毫秒?

I'm sure there's a reason I have to add three zeros to every Unix timestamp in JavaScript in order to get the correct date. Can you tell me why? Is it as simple as milliseconds since the epoch vs. seconds?

推荐答案

因为Javascript在内部使用毫秒,而正常的UNIX时间戳通常是在几秒钟内。

Because Javascript uses milliseconds internally, while normal UNIX timestamps are usually in seconds.

这篇关于为什么我需要在JavaScript中将unix时间戳乘以1000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆