简体   繁体   English

JavaScript日期构造函数和时区

[英]JavaScript date constructor and timezone

The Date constructor in JavaScript/ECMAScript/JScript allows passing the number of milliseconds since midnight, 1/1/1970. 在JavaScript / ECMAScript / JScript中的Date构造函数允许传递自1970年1月1日午夜以来的毫秒数。 Nowhere can I find documentation whether this is midnight in the client machine's timezone, or midnight GMT. 无论在客户机器的时区还是格林威治标准时间午夜,我都无法找到文件是否是午夜。 Which is it? 这是什么? Can it be relied on between different browsers and versions? 它可以依赖于不同的浏览器和版本吗? Is this officially documented anywhere? 这是官方记录在哪里吗?

From the ECMAScript specification : ECMAScript规范

Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. 自UTC时间1970年1月1日起,时间以ECMAScript为单位,以毫秒为单位。 In time values leap seconds are ignored. 在时间值中,忽略闰秒。 It is assumed that there are exactly 86,400,000 milliseconds per day. 假设每天恰好有86,400,000毫秒。 ECMAScript Number values can represent all integers from –9,007,199,254,740,991 to 9,007,199,254,740,991; ECMAScript数值可以表示从-9,007,199,254,740,991到9,007,199,254,740,991的所有整数; 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. 此范围足以测量从UTC时间1970年1月1日起向前或向后约285,616年内的任何瞬间的毫秒精度。

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. ECMAScript日期对象支持的实际时间范围略小:相对于UTC时间1970年1月1日午夜测量的时间恰好为-100,000,000天到100,000,000天。 This gives a range of 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC. 这给UTC时间1970年1月1日的任何一方提供了8,640,000,000,000,000毫秒的范围。

The exact moment of midnight at the beginning of 01 January, 1970 UTC is represented by the value +0. 1970年1月1日开始的午夜的确切时刻由值+0表示。

So to answer your question, it's Coordinated Universal Time . 所以回答你的问题,它是协调世界时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM