# Timezone problem/question again

**URL:** https://discuss.elastic.co/t/timezone-problem-question-again/258180
**Category:** Elasticsearch
**Created:** [December 9, 2020, 8:02pm UTC](https://discuss.elastic.co/t/timezone-problem-question-again/258180 "2020-12-09T20:02:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)
#### Post date: [December 9, 2020, 8:02pm UTC](https://discuss.elastic.co/t/timezone-problem-question-again/258180/1 "2020-12-09T20:02:48Z")

</div>

In past I had problem with datestamp field but resolve by using this

same index  
read data from source -\> logstash -\> send Field1 to ELK as is and it will be converted to UTC and convert it back to local time via Kibana

read data from source -\> logstash -\> create new field1\_timezone=UTC -\> send to ELK and it will be saved as is.

in above case I can use field1 for kibana, and Field1\_timezone for sql query. and All works

* * *

now reading data via python and this logic is not working.

how do I save datetime that I get from source to ELK without change and it will convert to UTC by default.? it is moving day out

for example  
{'count': 130, 'status\_achieved': datetime.datetime(2020, 11, 3, 0, 0), 'status\_achieved\_timezone': datetime.datetime(2020, 11, 3, 0, 0, tzinfo=\<StaticTzInfo 'Etc/UTC'\>), 'timestamp': datetime.datetime(2020, 12, 9, 19, 16, 17, 280173), '\_id': 'xyz1234567'}

in above 'status\_achieved" is same as I got from source.  
status\_achieved\_timezone is converted to UTC

This record should show up on date 11/03/2020 but on kibana it shows up on 11/02/2020

This how the record shows up in discovery

```
{
    "status_achieved": "2020-11-03T00:00: **00-05:51**",
    "status_achieved_timezone": "2020-11-03T00:00:00+00:00",
     "count": 130,
    "timestamp": "2020-11-19T13:16:44.085568",
 },
  "fields": {
    "status_achieved": [
      "2020-11-03T05:51:00.000Z"
    ],
    "status_achieved_timezone": [
      "2020-11-03T00:00:00.000Z"
    ],
    "timestamp": [
      "2020-11-19T13:16:44.085Z"
    ]
  },

```

This how I am converting time in python

```
   datetime_obj_utc = mytime_timestamp.replace(tzinfo=timezone('Etc/UTC'))
   datetime_obj_cst = mytime_timestamp.replace(tzinfo=timezone('America/Chicago'))
```

---

<div class="post-metadata">

### Author: ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)
#### Post date: [December 10, 2020, 2:40pm UTC](https://discuss.elastic.co/t/timezone-problem-question-again/258180/2 "2020-12-10T14:40:22Z")

</div>

this is fixed. used following

```
   datetime_obj_cst = pytz.timezone('America/Chicago').localize(mytime_timestamp)
   datetime_obj_utc = pytz.timezone('Etc/UTC').localize(mytime_timestamp)
```

---

<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: [January 7, 2021, 2:40pm UTC](https://discuss.elastic.co/t/timezone-problem-question-again/258180/3 "2021-01-07T14:40:43Z")

</div>

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