# TimeZone issue in GET API

**URL:** <https://discuss.elastic.co/t/timezone-issue-in-get-api/246462>\
**Category:** Kibana\
**Created:** [August 26, 2020, 2:07pm UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462 "2020-08-26T14:07:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![subash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subash/32/59912_2.png) [@subash](https://discuss.elastic.co/u/subash)\
**Post date:** [August 26, 2020, 2:07pm UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462/1 "2020-08-26T14:07:12Z")

</div>

Hi,  
I am facing a challenge in displaying the dateTime field in local time zone.

When I filter the data in kibana 'Discover' I am getting the date and time in local time zone.  
But when I query using the GET API in dev tools, I am not getting the results in local time zone but in UTC.

Below is the API I am running to fetch the data from 2020-08-25T00:00:00 to 2020-08-26T00:00:00.  
`````````````````````````````````````````````````````````````````````  
GET systemload-log/\_search  
{  
"size": 10000,  
"aggs": {  
"range": {  
"date\_range": {  
"field": "generateTime\_readable",  
"time\_zone":"Asia/Calcutta",  
"ranges": [  
{  
"from":" **2020-08-25T00:00:00.000Z**",  
"to":" **2020-08-26T00:00:00.000Z**"  
}  
]  
}  
}  
}  
}

`````````````````````````````````````````````````````````````````auto

Below is the first hit and the generateTime_readable value is 2020-08-25T14:40:00.000Z.
The records from 2020-08-25T00:00:00 to 2020-08-25T14:39:00 are missing though it exists.

`````````````````````````````````````````````
    "hits" : [
          {
            "_index" : "systemload-log",
            "_type" : "_doc",
            "_id" : "aJcPJnQBBTV2xJn45Ksl",
            "_score" : 1.0,
            "_source" : {
              "host" : "xxx"
              "memLoad" : "23",
              "message" : "hidden",
              "tenantId" : "2",
              "diskLoad" : "6",
              "port" : 56514,
              "timestamp" : "2020-08-25T14:39:49+0000",
              "Type" : "systemLoadLog",
              "vsnId" : "0",
              "cpuLoad" : "0",
              "sessLoad" : "135",
              "@timestamp" : "2020-08-25T14:40:09.617Z",
              "applianceName" : "xxxx",
              "@version" : "1",
              "generateTime_readable" : **"2020-08-25T14:40:00.000Z"** ,
              "tenantName" : "test",
              "applianceId" : "0",
              "generateTime" : "1598366400"
            }
          },`
    ````````````````````````````````````````````````````````````````
Please help me to show the results in local time zone.
`````````````````````````````````````````````````````````````````

---

<div class="post-metadata">

**Author:** ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)\
**Post date:** [August 26, 2020, 10:41pm UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462/2 "2020-08-26T22:41:13Z")

</div>

Hello @subash

Discover converts time fields in documents to the local time. If you are consuming a raw api request then you must perform the conversion yourself.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 26, 2020, 10:57pm UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462/3 "2020-08-26T22:57:31Z")

</div>

This is a bit of a UX break in my opinion, I've created [https://github.com/elastic/kibana/issues/76050](https://github.com/elastic/kibana/issues/76050) to see what we can do here 🙂

---

<div class="post-metadata">

**Author:** ![subash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subash/32/59912_2.png) [@subash](https://discuss.elastic.co/u/subash)\
**Post date:** [August 27, 2020, 4:42am UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462/4 "2020-08-27T04:42:47Z")

</div>

> [@mattkime](#):
>
> If you are consuming a raw api request then you must perform the conversion yourself.

I have given "time\_zone":"Asia/Calcutta" in the API but still getting the results in UTC.  
I am not sure whether it is the correct way of doing.

Please suggest, how to do the time\_zone conversion in API.

---

<div class="post-metadata">

**Author:** ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)\
**Post date:** [August 27, 2020, 4:49am UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462/5 "2020-08-27T04:49:34Z")

</div>

`time_zone` is used as an argument for the date range aggregation and is not used to format the resulting document. Relevant docs - [Date range aggregation | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html)

> Please suggest, how to do the time\_zone conversion in API.

This isn't possible. You would need to covert the value with whatever code is consuming the API response.

---

<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:** [September 24, 2020, 4:49am UTC](https://discuss.elastic.co/t/timezone-issue-in-get-api/246462/6 "2020-09-24T04:49:42Z")

</div>

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