# Date Hist Aggregation - Recreating "post\_zone" (post ES 2.x)

**URL:** <https://discuss.elastic.co/t/date-hist-aggregation-recreating-post-zone-post-es-2-x/35109>\
**Category:** Elasticsearch\
**Created:** [November 20, 2015, 1:33am UTC](https://discuss.elastic.co/t/date-hist-aggregation-recreating-post-zone-post-es-2-x/35109 "2015-11-20T01:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhuang](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jhuang](https://discuss.elastic.co/u/jhuang)\
**Post date:** [November 20, 2015, 1:33am UTC](https://discuss.elastic.co/t/date-hist-aggregation-recreating-post-zone-post-es-2-x/35109/1 "2015-11-20T01:33:31Z")

</div>

Hello,

Pre ES 2.x, I use the Date Histogram Aggregation and in particular the time zone related fields (pre\_zone/post\_zone), to aggregate data and return in the correct time zones.

I understand that in ES2.x, time\_zone fully replaces pre\_zone. However, the post\_zone function has been completely dropped. This was rather valuable as I was able to give ES a timezone, and it would return the data bucketed in the correct time AND return the timestamp key for the BEGINNING of the interval. Now, it seems that there isn't a way to replicate post\_zone without bringing all the date keys into the application and doing the date offset and rounding based on the interval.

Am I missing something? Is the post\_zone function still producible in some manner? This almost seems like a regression in function to me...

Thanks.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 20, 2015, 12:36pm UTC](https://discuss.elastic.co/t/date-hist-aggregation-recreating-post-zone-post-es-2-x/35109/2 "2015-11-20T12:36:07Z")

</div>

Hi,

the bucket keys in the aggregation are now always returned in UTC millis. If you want to display the value in the time zone that you use in the aggregation, this is returned in the `key_as_string`

- the `time_zone` parameter shifts bucket boundaries to start/stop according to the specified time\_zone
- in the returned bucket: `key_as_string` returns a formated version of that key in the specified timezone, e.g. for `"time_zone": "-02:00"`, a daily bucket would contain `"key_as_string" : "2014-05-26T00:00:00.000-02:00"`, so this can be used to display local time instead of UTC. You can also specify different formats in the request, like e.g. with `"format": "yyyy-MM-dd/HH:mm.ss"` your would get `"2014-05-26/00:00.00"`

Hope this solves your problem.

---

<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 5, 2017, 11:36pm UTC](https://discuss.elastic.co/t/date-hist-aggregation-recreating-post-zone-post-es-2-x/35109/3 "2017-07-05T23:36:55Z")

</div>


