# Convert date to 2019-09-11T15:47:00Z from 11/09/2019 15:47

**URL:** <https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826>\
**Category:** Logstash\
**Created:** [September 24, 2019, 9:13am UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826 "2019-09-24T09:13:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [September 24, 2019, 9:13am UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/1 "2019-09-24T09:13:12Z")

</div>

Hi all

can someone help me how to convert the column value in csv from the date 11/09/2019 15:47 to 2019-09-11T15:47:00Z format

Thanks

---

<div class="post-metadata">

**Author:** ![chandu5565](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@chandu5565](https://discuss.elastic.co/u/chandu5565)\
**Post date:** [September 24, 2019, 10:22am UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/2 "2019-09-24T10:22:07Z")

</div>

> [@kolli\_dilip](#):
>
> 11/09/2019 15:47

Try this filter this would work for you

```auto
filter {
   grok {
match => {"message" => "%{DATE:date} %{HOUR:hour}:%{MINUTE:minute}"}
  }
    mutate {
  add_field => { "timestamp" => "%{date} %{hour}:%{minute}" }
  }
   date {
      match => ["timestamp", "dd/MM/yyyy HH:mm"]
        }
  }

```

---

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [September 24, 2019, 11:01am UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/3 "2019-09-24T11:01:50Z")

</div>

when passing the timestamp in ruby filter, as below

there is an exception :

> Ruby exception occurred: no implicit conversion of LogStash::Timestamp into String

> ruby  
> {  
> init =\> "require 'date'"  
> code =\> '  
> duration = 0.0  
> createtime= event.get("@timestamp")  
> ctime = DateTime.parse(createtime)  
> event.set("Total\_duration\_sec", ctime)  
> '  
> }

i need to parse this date using the DateTime.parse

Thanks

---

<div class="post-metadata">

**Author:** ![chandu5565](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@chandu5565](https://discuss.elastic.co/u/chandu5565)\
**Post date:** [September 24, 2019, 12:56pm UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/4 "2019-09-24T12:56:15Z")

</div>

Add the filter configuration i gave. Output should be like below. I hope you are looking for this only.

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d7e56b84ebbbeb10c67d51562b70549a7a86f631.png)

@timestamp field is updated with the time field that you have given.

---

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [September 24, 2019, 1:11pm UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/5 "2019-09-24T13:11:48Z")

</div>

Hi Chandu.. thanks for your time on this  
I used the below datefilter which gives me @timestamp in 2019-09-11T15:47:00Z format but it was of 'date' type.. need this @timestamp to be converted 'string' .. so that it can be used for parsing in ruby "createtime= event.get("@timestamp")  
ctime = DateTime.parse(createtime)"

> date  
> {  
> match =\> ["Time\_Closed", "dd/MM/yyyy HH:mm"]  
> timezone =\> "Europe/London"  
> target =\> "@timestamp"   
> }

---

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [September 25, 2019, 2:25am UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/6 "2019-09-25T02:25:46Z")

</div>

> [@kolli\_dilip](#):
>
> but it was of 'date' type.. need this @timestamp to be converted 'string'

i used the ruby .to\_s for the string conversion... which worked 🙂 Thanks Chandu for your time...

---

<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:** [October 23, 2019, 2:25am UTC](https://discuss.elastic.co/t/convert-date-to-2019-09-11t1500z-from-11-09-2019-15-47/200826/7 "2019-10-23T02:25:54Z")

</div>

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