为什么我需要在 JavaScript 中将 unix 时间戳乘以 1000?

2022-01-13 00:00:00 timestamp javascript unix-timestamp

我确信我必须为 JavaScript 中的每个 Unix 时间戳添加三个零以获取正确的日期是有原因的.你能告诉我为什么吗?自纪元以来的毫秒数与秒数一样简单吗?

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.

相关文章