Elasticsearch 中日期末尾的 Z 是什么

What is The Z at the end of Date in Elasticsearch

为什么在 Elasticsearch 中我们有 'Z' 在日期字段的末尾?

例如:

2016-05-16T00:00:00.000Z

这是什么意思?

这个有用吗?

有害吗?

我可以摆脱它吗?

joda时间呢?

What does it mean?

'Z' 表示 UTC。
参考:
https://www.w3.org/TR/NOTE-datetime

尽量不要存储本地日期。如果你想找到关于日期的好帖子以及为什么你应该使用 UTC 检查 this thread.

Is this something useful for anything?

这非常有用,以 UTC 格式存储所有日期可以轻松地将日期从区域设置转换为区域设置。它还允许日期比较和日期可视化保持一致。

Is it harmful?

没有

Can I get rid of it?

如果你愿意?我不建议这样做......这有点像从交易中删除货币字段。这笔交易没有任何意义。

另一个带日期的例子:

我于 2016 年 12 月 24 日下午 1 点打电话给我在 X 国的朋友(提前 6 小时)。 对他来说是晚上 7 点。 所以我们有两个 local 日期时间。

给我一个:

1pm December 24th 2016 in London

一个给我的朋友:

7pm December 24th 2016 in Country X

如果我删除 'in ...' 部分,这两个部分将成为两个时间间隔为 5 小时的实例。这意味着我们不可能在 phone 上发言?对吗?

不,因为它们在时间上是同一个实例,跨越两个语言环境。

What about joda time?

怎么样?...

希望对您有所帮助。

来自 RFC3339 关于 Internet 上的日期和时间:

Numeric offsets are calculated as "local time minus UTC". So the equivalent time in UTC can be determined by subtracting the offset from the local time. For example, 18:50:00-04:00 is the same time as 22:50:00Z. (This example shows negative offsets handled by adding the absolute value of the offset.)

因此,以 Z 结尾的日期是 UTC 中的日期和时间。它应该相当于 2016-05-16T00:00:00.000Z-00:00.

是否存在时区偏移只是 date format being used in Elasticsearch's field definition.

的问题