Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is The Z at the end of Date in Elasticsearch

Why in Elasticsearch we have the 'Z' at the end of the date field?

For instance:

2016-05-16T00:00:00.000Z

What does it mean?

Is this something useful for anything?

Is it harmful?

Can I get rid of it?

What about joda time?

like image 424
Filipe Miranda Avatar asked May 10 '16 21:05

Filipe Miranda


People also ask

What does Z mean at end of date?

When “Z” (Zulu) is tacked on the end of a time, it indicates that that time is UTC, so really the literal Z is part of the time. What is T between date and time? The T is just a literal to separate the date from the time, and the Z means “zero hour offset” also known as “Zulu time” (UTC).

What is default date format in Elasticsearch?

SSSZ or yyyy-MM-dd .

What is this datetime format?

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts.

What is Epoch_Millis?

1. Epoch_Millis format is a timestamp format that is used in Elasticsearch. Elasticsearch is a powerful search engine that can be used to index and search data in a variety of formats. One of the formats that it supports is the Epoch_Millis format, which is a timestamp format that is used in Elasticsearch.


1 Answers

What does it mean?

The 'Z' means UTC.
Reference:
https://www.w3.org/TR/NOTE-datetime

Try not to store local dates. If you want to find a good thread on dates and why you should use UTC check this thread.

Is this something useful for anything?

It is very useful, storing all dates in UTC allows for easy conversion of dates from locale to locale. It also allows for date comparison and date visualisations to be consistent.

Is it harmful?

No.

Can I get rid of it?

If you wish? I wouldn't recommend doing it... It's a bit like removing the currency field from a transaction. The transaction doesn't make any sense.

Another example with dates:

I rang my friend in Country X (+6 hours ahead) at 1pm December 24th 2016. For him it was 7pm. So we have two local date times.

One for me:

1pm December 24th 2016 in London

One for my friend:

7pm December 24th 2016 in Country X

If I delete the 'in ...' Part these two become become two instances of time 5 hours apart of each other. Which means we couldn't have possibly spoken on the phone? Right?

No, because they are the same instance in time, across two locales.

What about joda time?

What about it?...

I hope this helps.

like image 192
Rhys Bradbury Avatar answered Nov 07 '22 18:11

Rhys Bradbury