什么是JavaScript Date.now()时间格式? [英] What is the JavaScript Date.now() time format called?

查看:1557
本文介绍了什么是JavaScript Date.now()时间格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在我的文档中写些什么。

I'm asking to know what to write in my documentation.

MDN 将其描述为:

MDN describes it as:


一个数字,表示自UNIX纪元以来经过的毫秒数。

A Number representing the milliseconds elapsed since the UNIX epoch.

虽然W3Schools 将其描述为:

While W3Schools describes it as:


毫秒数自1970/01/01以来

the number of milliseconds since 1970/01/01

然而,这些只是 description Unix时间的维基百科页面说明:

However, those are just descriptions. The Wikipedia page of Unix time states:


Unix时间是用于描述时间瞬间的系统,定义为自00:00:00协调世界时(UTC)以来经过的的数量, 1970年1月1日星期四[...]

Unix time is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970 [...]

秒。不是毫秒,由 Date.now()返回。所以我也不能把它称为unix时间格式。

Seconds. Not milliseconds, as returned by Date.now(). So I can't really call it the "unix time format" as well.

是否有数字表示自UNIX纪元时间格式具有更简洁的名称以来经过的毫秒数?

推荐答案

通常来说,如果你只是说Unix时间或Unix时间戳,暗示你是以秒为单位说话。但是,请理解POSIX规范实际上并未使用这些术语。相反,它特别说明了自大纪以来的秒,在第4.16节中定义,并在整个规范中使用。我们称之为Unix时间只是一种口语化。

Commonly speaking, if you just say "Unix Time" or "Unix Timestamp", it is implied that you are speaking in terms of seconds. However, understand that the POSIX specification doesn't actually use these terms. Instead, it specifically says "Seconds Since the Epoch", defined in section 4.16, and used throughout the spec. That we call it "Unix Time" at all is just a colloquialism.

ECMAScript规范8.0版的第20.3.1.1节,时间戳没有给出其他术语比UTC时间1970年1月1日以来的毫秒数。

In section 20.3.1.1 of version 8.0 of the ECMAScript specification, the timestamp is not given terminology other than "milliseconds since 01 January, 1970 UTC".

因此,当提到JavaScript(以及其他地方)中使用的时间戳时,你可以自由地称它为毫秒自(Unix)纪元以来,或以毫秒为单位的Unix时间,或以毫秒为单位的Unix时间戳。 没有普遍认可的口语术语或标准术语更简洁。

Therefore, when referring to the timestamps used in JavaScript (and elsewhere), you're free to call it "Milliseconds Since the (Unix) Epoch", or "Unix Time in Milliseconds", or "Unix Timestamp in Milliseconds". There is no universally recognized colloquial term or standard term that is more concise.

关于此主题的其他几点:

A few other points on this subject:


  • 您提供的W3Schools链接上的文字是一个重要的错误,因为它没有指定UTC。由于Unix Epoch是根据UTC定义的,因此从中派生的所有时间戳都是基于UTC的。

  • The text on the W3Schools link you gave makes a crucial mistake in that it doesn't specify UTC. Since the Unix Epoch is defined in terms of UTC, all timestamps derived from it are UTC based.

有些人可能将这些时间戳称为纪元时间。但是,这是荒谬的。请避免使用此术语,因为它意味着时间值本身就是一个时代。只有 0 值才能被视为时代。人们可能会说以纪元为基础的时间,但即使在那时,也存在哪个时代?的问题。虽然Unix时代很常见,但有计算中使用的多个不同时期

Some may refer to these timestamps as "epoch time". However, this is nonsensical. Please avoid using this terminology, as it implies the time value itself is an epoch. Only the 0 value can be considered the epoch. One might say "epoch-based time", but even then, there's a question of "which epoch?". Though the Unix epoch is common, there are multiple different epochs used in computing.

这篇关于什么是JavaScript Date.now()时间格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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