# How to format date in logstash

**URL:** https://discuss.elastic.co/t/how-to-format-date-in-logstash/112250
**Category:** Logstash
**Created:** [December 18, 2017, 2:33pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-logstash/112250 "2017-12-18T14:33:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![saidesh\_kilaru](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@saidesh\_kilaru](https://discuss.elastic.co/u/saidesh_kilaru)
#### Post date: [December 18, 2017, 2:33pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-logstash/112250/1 "2017-12-18T14:33:51Z")

</div>

I have date string and i need to convert that to date with specific format.  
for example: dattime="2017-12-12 11:12:00";  
date {  
match =\> ["dattime", "yyyy-MM-dd HH:mm:ss"]  
target =\> "dattime"  
}

when iam doing this iam getting date in iso 8601 format.

how can i get a date in specific format from a string/ how to format iso 8601 date to other date pattern (custom)

as i am new to logtash facing issues to solve this. please help me.  
Thanks in advance

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [December 18, 2017, 2:38pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-logstash/112250/2 "2017-12-18T14:38:11Z")

</div>

Formatting a timestamp in a specific format is something that should be done by the presentation layer so I think you're focusing on the wrong thing.

That said, the value produced by the date filter will be of a timestamp type that I think has methods for formatting (probably named strftime). If so you can use a ruby filter to call that method and format the timestamp in any way supported by the date library.

---

<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 15, 2018, 2:38pm UTC](https://discuss.elastic.co/t/how-to-format-date-in-logstash/112250/3 "2018-01-15T14:38:54Z")

</div>

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