# Converting a date input as a string into a new format

**URL:** <https://discuss.elastic.co/t/converting-a-date-input-as-a-string-into-a-new-format/177498>\
**Category:** Logstash\
**Created:** [April 18, 2019, 3:15pm UTC](https://discuss.elastic.co/t/converting-a-date-input-as-a-string-into-a-new-format/177498 "2019-04-18T15:15:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thadc](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@thadc](https://discuss.elastic.co/u/thadc)\
**Post date:** [April 18, 2019, 3:15pm UTC](https://discuss.elastic.co/t/converting-a-date-input-as-a-string-into-a-new-format/177498/1 "2019-04-18T15:15:33Z")

</div>

Hello, I have a need to convert a field value for a log time stamp from its current ISO8601 into a format of yyyy.mm.dd hh.mm.ss on output. I have a filter similar to the following:

filter {  
.  
. (grok section to parse input omitted for clarity)  
.  
date {  
match =\> ["logDateTime", "ISO8601"]  
target =\> "logDateTimeAlias"  
}  
}

so this date filter properly isolates all the logDateTime values and properly assigns them to the target logDateTimeAlias on output. However, date does not have to way to convert the field value to another format and I cannot find a filter that does except of date\_formatter which I cannot install the plugin for in my environment.

I would be grateful for any ideas on how to convert the format in the manner I am looking for. Thanks!

---

<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:** [April 18, 2019, 4:29pm UTC](https://discuss.elastic.co/t/converting-a-date-input-as-a-string-into-a-new-format/177498/2 "2019-04-18T16:29:21Z")

</div>

You could do it in Ruby. This works, but doesn't feel quite right.

```
    ruby {
        code => '
            t = event.get("@timestamp")
            event.set("dateTime", Time.at(t.to_f).strftime("%Y.%m.%d %H.%M.%S"))
        '
    }
```

---

<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:** [May 16, 2019, 4:29pm UTC](https://discuss.elastic.co/t/converting-a-date-input-as-a-string-into-a-new-format/177498/3 "2019-05-16T16:29:32Z")

</div>

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