最短和最长日期 [英] Minimum and maximum date

查看:166
本文介绍了最短和最长日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Javascript Date 对象允许的最小和最大日期。我发现最短的日期是200000 b.C.,但我无法得到任何参考。

I was wondering which is the minimum and the maximum date allowed for a Javascript Date object. I found that the minimum date is something like 200000 b.C., but I couldn't get any reference about it.

有谁知道答案?我只是希望它不依赖于浏览器。

Does anyone know the answer? I just hope that it doesn't depend on the browser.

epoch time中的答案(= 1970-01-01 00:00:00 UTC的毫秒数+00)将是最好的。

An answer in "epoch time" (= milliseconds from 1970-01-01 00:00:00 UTC+00) would be the best.

推荐答案

来自规范,§ 15.9.1.1


Date对象包含一个数字,表示在一毫秒内的特定时刻。这样的数字称为时间值。时间值也可以是NaN,表示Date对象不代表特定的时刻。

A Date object contains a Number indicating a particular instant in time to within a millisecond. Such a Number is called a time value. A time value may also be NaN, indicating that the Date object does not represent a specific instant of time.

时间以ECMAScript为单位,以毫秒为单位,自1970年1月1日UTC开始。在时间值中,忽略闰秒。假设每天恰好有86,400,000毫秒。 ECMAScript数值可以表示从-9,007,199,254,740,992到9,007,199,254,740,992的所有整数;此范围足以测量从UTC时间1970年1月1日起向前或向后约285,616年内的任何瞬间的毫秒精度。

Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day. ECMAScript Number values can represent all integers from –9,007,199,254,740,992 to 9,007,199,254,740,992; this range suffices to measure times to millisecond precision for any instant that is within approximately 285,616 years, either forward or backward, from 01 January, 1970 UTC.

实际范围ECMAScript支持的时间日期对象略小:相对于UTC时间1970年1月1日午夜测量的时间恰好为-100,000,000天到100,000,000天。这给出了UTC时间1970年1月1日左右的8,640,000,000,000,000毫秒范围。

The actual range of times supported by ECMAScript Date objects is slightly smaller: exactly –100,000,000 days to 100,000,000 days measured relative to midnight at the beginning of 01 January, 1970 UTC. This gives a range of 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC.

1970年1月1日午夜的确切时刻UTC由值+0。

The exact moment of midnight at the beginning of 01 January, 1970 UTC is represented by the value +0.

第三段是最相关的。根据该段,我们可以从新日期(-8640000000000000)获得每个规格的确切最早日期,即4月20日星期二,公元前271,821(BCE =之前 Common Era ,例如,年份-271,821)。

The third paragraph being the most relevant. Based on that paragraph, we can get the precise earliest date per spec from new Date(-8640000000000000), which is Tuesday, April 20th, 271,821 BCE (BCE = Before Common Era, e.g., the year -271,821).

这篇关于最短和最长日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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