"Z" 之前的值在 ISO8601 日期字符串中表示什么?

What does the values before "Z" indicate in a ISO8601 date string?

我正在努力理解ISO8601 time format

这个值是什么意思?

2019-11-14T00:55:31.820Z

我是这样理解的

2019-11-14 // November 14th, 2019 
T00:55:31  // 12:55 AM  in GMT time (London)
.820       // why is this needed or specified?
Z          // The "Z" indicates to store this as GMT time (London)

我不明白为什么这里需要.820。阅读它,这是指时区 820,即加利福尼亚州。

如果我去 Javascript 控制台并在有和没有 820 值的情况下写这个,我会得到相同的结果,基于我的语言环境(EST 时区)

new Date('2019-11-14T00:55:31.820Z') // Wed Nov 13 2019 19:55:31 GMT-0500 (Eastern Standard Time)
new Date('2019-11-14T00:55:31Z')     // Wed Nov 13 2019 19:55:31 GMT-0500 (Eastern Standard Time)

Z 之前的前缀值实际上是做什么的?

The "Z" indicates to store this as GMT time (London)

不,它表示 显示的时间值是 UTC,而不是你应该将它存储在 GMT/UTC。它告诉您解释所提供信息的时区。

I don't understand why the .820 is needed here. Reading into it, this refers to timezone 820, which is California.

那是毫秒,不是时区。进入 00:55:31 需要 820 毫秒(例如,距离 00:55:32 需要 180 毫秒)。

If I were to go to the Javascript console and write this with and without that 820 value, I would get the same results, based on my locale (EST time zone)

只是因为您引用的任何控制台的输出都不包括毫秒。如果您检查实际日期,您会发现它们相隔 820 毫秒:

const dt1 = new Date('2019-11-14T00:55:31.820Z');
const dt2 = new Date('2019-11-14T00:55:31Z');

console.log(dt1.valueOf() - dt2.valueOf()); // 820

Date 实例的基础值是它表示自 1970 年 1 月 1 日午夜 UTC 以来的毫秒数。因此,如果我们减去 d2 [这不没有来自 d1.820] [确实如此],我们看到它们相隔 820 毫秒。)