# Date formatting failing - string

**URL:** <https://discuss.elastic.co/t/date-formatting-failing-string/135237>\
**Category:** Elasticsearch\
**Created:** [June 9, 2018, 7:21pm UTC](https://discuss.elastic.co/t/date-formatting-failing-string/135237 "2018-06-09T19:21:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![javidr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javidr/32/136982_2.png) [@javidr](https://discuss.elastic.co/u/javidr)\
**Post date:** [June 9, 2018, 7:21pm UTC](https://discuss.elastic.co/t/date-formatting-failing-string/135237/1 "2018-06-09T19:21:29Z")

</div>

Hi

Im using the python library to insert data in elasticsearch

Im trying to format the date i have in epoch format as datetime field

dt = time.strftime('%y-%m-%d %H:%M:%S', time.localtime(float(d['timestamp'])))  
dt = datetime.strptime(dt, '%y-%m-%d %H:%M:%S')  
d['timestamp']=dt  
es.index(index='test', doc\_type='json', id=i, body=d)

However, when accessing the data in kibana, the field timestamp is still considered as a string

What should i do to be able to convert this field to a format that elasticsearch can understand?

If i check in discover, the format is like this:

| timestamp | |
| --- | --- |
| | 2018-06-09T20:17:21 |

Which looks like a proper timestamp field

Thanks

---

<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 7, 2018, 7:21pm UTC](https://discuss.elastic.co/t/date-formatting-failing-string/135237/2 "2018-07-07T19:21:33Z")

</div>

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