# How to change date format in logstash?

**URL:** <https://discuss.elastic.co/t/how-to-change-date-format-in-logstash/257532>\
**Category:** Logstash\
**Created:** [December 3, 2020, 3:22pm UTC](https://discuss.elastic.co/t/how-to-change-date-format-in-logstash/257532 "2020-12-03T15:22:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reillye](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@reillye](https://discuss.elastic.co/u/reillye)\
**Post date:** [December 3, 2020, 3:22pm UTC](https://discuss.elastic.co/t/how-to-change-date-format-in-logstash/257532/1 "2020-12-03T15:22:01Z")

</div>

My raw data comes in epoch format e.g. `430201865`. I can parse this to UNIX using the `date` filter in logstash like so

```
date {
  match => ["time", "UNIX"]
  target => "timestamp"
  remove_field => ["time"]
}

```

This produces the date in a format like so: `1983-08-20T20:50:10.000Z`, but I have a format on my Elasticsearch template for my index like so `uuuu-MM-dd HH:mm:ss Z`. This results in an error when parsing the date, as it does not match the format we are expecting.

Is there a way for me to convert the my date into the format I am expecting?

---

<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:** [December 3, 2020, 4:16pm UTC](https://discuss.elastic.co/t/how-to-change-date-format-in-logstash/257532/2 "2020-12-03T16:16:29Z")

</div>

> [@reillye](#):
>
> Is there a way for me to convert the my date into the format I am expecting?

Use a ruby filter and [strftime](https://discuss.elastic.co/t/date-field-being-converted-to-timestamps/180044/4).

---

<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:** [December 31, 2020, 4:16pm UTC](https://discuss.elastic.co/t/how-to-change-date-format-in-logstash/257532/3 "2020-12-31T16:16:32Z")

</div>

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