# Strange time\_zone behavior with date histogram facet

**URL:** <https://discuss.elastic.co/t/strange-time-zone-behavior-with-date-histogram-facet/6220>\
**Category:** Elasticsearch\
**Created:** [December 22, 2011, 3:35pm UTC](https://discuss.elastic.co/t/strange-time-zone-behavior-with-date-histogram-facet/6220 "2011-12-22T15:35:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Caffee](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Allan\_Caffee](https://discuss.elastic.co/u/Allan_Caffee)\
**Post date:** [December 22, 2011, 3:35pm UTC](https://discuss.elastic.co/t/strange-time-zone-behavior-with-date-histogram-facet/6220/1 "2011-12-22T15:35:45Z")

</div>

I'm a little confused by the behavior of a date\_histogram. My  
understanding from the documentation  
([http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html](http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html))  
is that a when providing a "time\_zone" in the facet ElasticSearch will  
adjust the "time" returned for each bucket to be milliseconds from epoch in  
the specified "time\_zone" (defaulting to UTC). But when I test this out as  
shown in this gist: [https://gist.github.com/1510658](https://gist.github.com/1510658) it doesn't seem to be  
adjusting the returned "time"s at all.

Do I need to set up a mapping of some kind on the index to tell it that the  
times are in UTC, or something?

Also is there a way to change the format of the returned "time"s to be an  
ISO format date string?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 22, 2011, 9:07pm UTC](https://discuss.elastic.co/t/strange-time-zone-behavior-with-date-histogram-facet/6220/2 "2011-12-22T21:07:26Z")

</div>

Heya, yea, something is strange. Trying to track it down with the date  
library I use, can you open an issue so we won't loose track of this?

On Thu, Dec 22, 2011 at 5:35 PM, Allan Caffee [allan.caffee@gmail.com](mailto:allan.caffee@gmail.com)wrote:

> I'm a little confused by the behavior of a date\_histogram. My  
> understanding from the documentation (  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html))  
> is that a when providing a "time\_zone" in the facet Elasticsearch will  
> adjust the "time" returned for each bucket to be milliseconds from epoch in  
> the specified "time\_zone" (defaulting to UTC). But when I test this out as  
> shown in this gist: [Strange date histogram facet behavior with ElasticSearch version 0.18.5 · GitHub](https://gist.github.com/1510658) it doesn't seem to be  
> adjusting the returned "time"s at all.
> 
> Do I need to set up a mapping of some kind on the index to tell it that  
> the times are in UTC, or something?
> 
> Also is there a way to change the format of the returned "time"s to be an  
> ISO format date string?

---

<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:** [July 6, 2017, 3:44am UTC](https://discuss.elastic.co/t/strange-time-zone-behavior-with-date-histogram-facet/6220/3 "2017-07-06T03:44:31Z")

</div>


