# Handling Time Zones and Daylight saving time

**URL:** <https://discuss.elastic.co/t/handling-time-zones-and-daylight-saving-time/83661>\
**Category:** Elasticsearch\
**Created:** [April 26, 2017, 7:36am UTC](https://discuss.elastic.co/t/handling-time-zones-and-daylight-saving-time/83661 "2017-04-26T07:36:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Henrique\_PH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulo_henrique_ph/32/14831_2.png) [@Paulo\_Henrique\_PH](https://discuss.elastic.co/u/Paulo_Henrique_PH)\
**Post date:** [April 26, 2017, 7:36am UTC](https://discuss.elastic.co/t/handling-time-zones-and-daylight-saving-time/83661/1 "2017-04-26T07:36:33Z")

</div>

Hi guys,

I've got a user case where a customer is struggling to get the right aggregations due to the Daylight saving time.

We are applying the offset factor (eg -01:00) and seems like it isn't enough.

I've read a topic here (below) which states that, in order to get it right, I gotta provide the ID (e.g. "US/Central") .

> [@Handling 1d date\_histogram queries that span Daylight Saving Time (Nov 6th 2 am)](https://discuss.elastic.co/t/handling-1d-date-histogram-queries-that-span-daylight-saving-time-nov-6th-2-am/69623):
>
> I store all my documents with date/times in GMT. Then at query time I use the "time\_zone" property of a date\_histogram to choose which timezone to localize it to (we have users in multiple time zones). This works great; however, I have ran into a problem for queries that span the daylight saving time change on Nov 6th and use 1d intervals. The problem arises because on Nov 6 at 2am the timezone offset changes e.g. on Nov 6th at 1 am the US Central timezone is GMT-0500, at Nov 6th at 2am the US…

Is it true?

---

<div class="post-metadata">

**Author:** ![yeppers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeppers/32/8078_2.png) [@yeppers](https://discuss.elastic.co/u/yeppers)\
**Post date:** [April 26, 2017, 1:52pm UTC](https://discuss.elastic.co/t/handling-time-zones-and-daylight-saving-time/83661/2 "2017-04-26T13:52:14Z")

</div>

Yes, using the raw offset of -01:00 will not take daylight savings time into account if your query spans a daylight savings time change. Instead pass in a timezone ID. Using a timezone ID like "US/Central", "Australia/Sydney", etc makes ES aware of daylight savings time even if the change happens during the span of your query.

When I was using a -0500 offset and doing a query that spanned the fall daylight savings time change with 1h intervals I was getting one additional bucket. Changing to US/Central gave me the expected number of buckets.

---

<div class="post-metadata">

**Author:** ![Paulo\_Henrique\_PH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulo_henrique_ph/32/14831_2.png) [@Paulo\_Henrique\_PH](https://discuss.elastic.co/u/Paulo_Henrique_PH)\
**Post date:** [April 27, 2017, 6:11am UTC](https://discuss.elastic.co/t/handling-time-zones-and-daylight-saving-time/83661/3 "2017-04-27T06:11:17Z")

</div>

Thanks @yeppers

---

<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:** [May 25, 2017, 6:17am UTC](https://discuss.elastic.co/t/handling-time-zones-and-daylight-saving-time/83661/4 "2017-05-25T06:17:49Z")

</div>

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