# How to specify timezone on elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614>\
**Category:** Elasticsearch\
**Created:** [December 25, 2020, 2:37am UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614 "2020-12-25T02:37:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel.goncalves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel.goncalves/32/47574_2.png) [@gabriel.goncalves](https://discuss.elastic.co/u/gabriel.goncalves)\
**Post date:** [December 25, 2020, 2:37am UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/1 "2020-12-25T02:37:12Z")

</div>

> **[Date field type | Elasticsearch Reference \[7.10\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html#CO37-3)**

It says: "Internally, dates are converted to UTC **(if the time-zone is specified)** and stored as a long number representing milliseconds-since-the-epoch."

What are all possible ways to specify the timezone?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 25, 2020, 3:03am UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/2 "2020-12-25T03:03:25Z")

</div>

Here:

```
PUT my-index-000001/_doc/2
{ "date": "2015-01-01T12:10:30Z" }

```

`Z` is the timezone here.

---

<div class="post-metadata">

**Author:** ![gabriel.goncalves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel.goncalves/32/47574_2.png) [@gabriel.goncalves](https://discuss.elastic.co/u/gabriel.goncalves)\
**Post date:** [December 25, 2020, 3:50am UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/3 "2020-12-25T03:50:40Z")

</div>

I'm sorry, but how does the character 'Z' specify which timezone this date-time belongs to?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 25, 2020, 8:23am UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/4 "2020-12-25T08:23:54Z")

</div>

In that cas Z means UTC.

You can have a look at this:

> **[DateTimeFormatter (Java Platform SE 8 )](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html)**

```
+01:00[Europe/Paris]

```

Is another timezone for example

```
+01:00

```

This one as well

---

<div class="post-metadata">

**Author:** ![gabriel.goncalves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel.goncalves/32/47574_2.png) [@gabriel.goncalves](https://discuss.elastic.co/u/gabriel.goncalves)\
**Post date:** [December 25, 2020, 4:56pm UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/5 "2020-12-25T16:56:18Z")

</div>

I see. So the allowed formats are ISO 8601. So are all of them allowed or just the Predefined Formatters in this Java class? And what should have 'allowed me to guess' this is the case from the link I provided first? I'm asking because since this isn't written there its probably 'obvious' for some reason.

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [December 26, 2020, 2:07am UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/6 "2020-12-26T02:07:53Z")

</div>

what method are you using to put data in python? logstash?

this is what you do on python. this will not change time but add timezone to the date.  
elastic will change that to UTC and save it. Kibana will convert it back to CST time and shows it on proper timeframe on graph  
datetime\_obj\_cst = pytz.timezone('America/Chicago').localize(mytime\_timestamp)

on logstash you don't have to do anything. it will automatically take timezone from system and make it utc and then save it in ELK. and Kibana will convert it back to cst and show you on proper place

date {  
match =\> ["mytime\_timestamp", "dd-MMM-yy HH:mm", "ISO8601"]  
target =\> "mytime\_timestamp"  
}

but if you still want to add timezone  
date {  
match =\> ["mytime\_timestamp", "dd-MMM-yy HH:mm", "ISO8601"]  
timezone =\> "America/Chicago"  
target =\> "mytime\_timestamp"  
}

Please try to understand how it is saved in elk and how you retrieve it.

---

<div class="post-metadata">

**Author:** ![gabriel.goncalves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel.goncalves/32/47574_2.png) [@gabriel.goncalves](https://discuss.elastic.co/u/gabriel.goncalves)\
**Post date:** [December 26, 2020, 6:19pm UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/7 "2020-12-26T18:19:38Z")

</div>

@elasticforme Thanks for the reply! And good to know that logstash does it automatically with some configuration. But I'm indexing documents from a C# console.

@dadoonet Sorry man, I kept asking and forgot to thank your reply. Thanks! Just making me clear - my last question was because if it was obvious for some reason, I should know the reason because it will probably also be omitted in other docs of other platforms/frameworks. My guess now is that "virtually every platform uses ISO 8601 for date formats so it can be omitted" - but if thats true I'm not aware of it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 23, 2021, 6:19pm UTC](https://discuss.elastic.co/t/how-to-specify-timezone-on-elasticsearch/259614/8 "2021-01-23T18:19:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
