# Convert epoch time to date

**URL:** <https://discuss.elastic.co/t/convert-epoch-time-to-date/223153>\
**Category:** Logstash\
**Created:** [March 11, 2020, 2:13pm UTC](https://discuss.elastic.co/t/convert-epoch-time-to-date/223153 "2020-03-11T14:13:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehulshah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehulshah/32/64234_2.png) [@mehulshah](https://discuss.elastic.co/u/mehulshah)\
**Post date:** [March 11, 2020, 2:13pm UTC](https://discuss.elastic.co/t/convert-epoch-time-to-date/223153/1 "2020-03-11T14:13:16Z")

</div>

[Edited] I am using Logstash 7.x version  
I have log like below where scheduledTime is in epoch long number,  
{"scheduledTime":1580634058274,"processTime":1580634073293,"mailingType":1,"userId":123}

I want it to be indexed to ES in below format through logstash  
{"scheduledTime":"Wed Mar 11 2020 14:08:11","processTime":1580634073293,"mailingType":1,"userId":123}

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [March 11, 2020, 3:00pm UTC](https://discuss.elastic.co/t/convert-epoch-time-to-date/223153/2 "2020-03-11T15:00:20Z")

</div>

You can use a date filter to convert an epoch time into a LogStash::Timestamp, then use ruby and strftime to convert it into a string in whatever format you want.

---

<div class="post-metadata">

**Author:** ![mehulshah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehulshah/32/64234_2.png) [@mehulshah](https://discuss.elastic.co/u/mehulshah)\
**Post date:** [March 12, 2020, 10:32am UTC](https://discuss.elastic.co/t/convert-epoch-time-to-date/223153/3 "2020-03-12T10:32:14Z")

</div>

Thank you Badger, below works for me.  
date {  
match =\> ["scheduledTime","UNIX\_MS"]  
target =\> "scheduledTime"  
timezone =\> "UTC"  
}

---

<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:** [April 9, 2020, 10:32am UTC](https://discuss.elastic.co/t/convert-epoch-time-to-date/223153/4 "2020-04-09T10:32:15Z")

</div>

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