# Timezone in ES Python Client

**URL:** <https://discuss.elastic.co/t/timezone-in-es-python-client/114099>\
**Category:** Elasticsearch\
**Created:** [January 4, 2018, 1:48pm UTC](https://discuss.elastic.co/t/timezone-in-es-python-client/114099 "2018-01-04T13:48:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shin1](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@shin1](https://discuss.elastic.co/u/shin1)\
**Post date:** [January 4, 2018, 1:48pm UTC](https://discuss.elastic.co/t/timezone-in-es-python-client/114099/1 "2018-01-04T13:48:55Z")

</div>

Hi All,

I'm new to ES Python Client ([https://elasticsearch-py.readthedocs.io/en/master/](https://elasticsearch-py.readthedocs.io/en/master/)) and have an odd issue on query result from Elasticsearch.search().  
Queried data has a datetime field holding UTC timestamp but Elasticsearch.search() returns it in my local timezone, which is UTS+9.  
It looks like Elasticsearch.search() automatically(by default?) converts the datetime field into my local timezone.

I'd like to confirm if this is an expected behavior and how I can set customized timezone in Elasticsearch.search().

Many thanks in advance for your help!  
Regards,  
Sat

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [January 12, 2018, 5:43pm UTC](https://discuss.elastic.co/t/timezone-in-es-python-client/114099/2 "2018-01-12T17:43:53Z")

</div>

Hi @shin1,

I don't think it converts datetime fields to local timezone. Please take a look in the following example:

```
#Index one document in UTC
POST index/doc/1
{
  "date": "2018-01-12T00:00:00Z"
} 

```

Search using elasticsearch-py:

```
from elasticsearch import Elasticsearch

es = Elasticsearch()
result = es.search(index="index", body={
    "query": {
        "range": {
            "date": {
                "gte": "2018||/y"
            }
        }
    }
})
print result["hits"]["hits"][0]["_source"]["date"]

```

Execute the code:

```
$ python search_date.py
$ 2018-01-12T00:00:00Z --> as indexed

```

I'm in UTC -2:00

Cheers,  
LG

---

<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:** [February 9, 2018, 5:43pm UTC](https://discuss.elastic.co/t/timezone-in-es-python-client/114099/3 "2018-02-09T17:43:56Z")

</div>

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