# Date parsing problems

**URL:** <https://discuss.elastic.co/t/date-parsing-problems/181843>\
**Category:** Logstash\
**Created:** [May 20, 2019, 2:03pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843 "2019-05-20T14:03:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ta7643](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@ta7643](https://discuss.elastic.co/u/ta7643)\
**Post date:** [May 20, 2019, 2:03pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843/1 "2019-05-20T14:03:22Z")

</div>

Hi,

I have a very strange behavior when parsing date. Does anybody understand this behavior?  
Here the config:

```
input { stdin { codec => json} }
filter {
 if [last_seen]{
   date {
    tag_on_failure => true
    match => ["last_seen", "dd.MM.YYYY HH:mm"]
    target => "@timestamp_last_seen"
   }
 } 
}
output { stdout { codec => rubydebug } }

```

And here 3 examples:

1. 

```
{"last_seen": "31.03.2019 01:59"}
{
                    "host" => "example",
                "@version" => "1",
               "last_seen" => "31.03.2019 01:59",
              "@timestamp" => 2019-05-20T13:47:47.855Z,
    "@timestamp_last_seen" => 2019-03-31T00:59:00.000Z
}

```

1. 

```
{"last_seen": "31.03.2019 02:00"}
{
          "host" => "example",
          "tags" => [
        [0] "true"
    ],
      "@version" => "1",
     "last_seen" => "31.03.2019 02:00",
    "@timestamp" => 2019-05-20T13:48:00.090Z
}

```

why the above example failed??  
If i change the day of the month from 31 to 30 it works again. But 31.03.2019 exists and the expected output should be only 1 minute different from the one in the first example.

1. 

```
{"last_seen": "30.03.2019 02:00"}
{
                    "host" => "example",
                "@version" => "1",
               "last_seen" => "30.03.2019 02:00",
              "@timestamp" => 2019-05-20T13:48:36.551Z,
    "@timestamp_last_seen" => 2019-03-30T01:00:00.000Z
}

```

Thx in advance

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 20, 2019, 2:07pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843/2 "2019-05-20T14:07:59Z")

</div>

Hi,  
thanks for the config, very quick problem replication. 🙂

> {"last\_seen": "31.03.2019 01:59"} - works : 2019-03-31T00:59:00.000Z  
> {"last\_seen": "31.03.2019 02:00"} - failed to parse  
> {"last\_seen": "31.03.2019 02:11"} - failed to parse  
> {"last\_seen": "31.03.2019 02:59"} - failed to parse  
> {"last\_seen": "31.03.2019 03:00"} - works : 2019-03-31T01:00:00.000Z

According to the calendar such date exists, but Logstash seems to have 1 hour parsing problem between 2019-03-31T01:00:00.000Z- 2019-03-31T01:59:00.000Z

To be honest it looks like a date parsing corner case.

---

<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:** [May 20, 2019, 2:13pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843/3 "2019-05-20T14:13:46Z")

</div>

> [@ta7643](#):
>
> {"last\_seen": "31.03.2019 02:00"}

What date did daylight savings time start in your timezone? Did time go from 01:59:59 to 03:00:00 that day?

---

<div class="post-metadata">

**Author:** ![ta7643](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@ta7643](https://discuss.elastic.co/u/ta7643)\
**Post date:** [May 20, 2019, 2:16pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843/4 "2019-05-20T14:16:15Z")

</div>

Thats it!.. Thanks a lot

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 20, 2019, 2:18pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843/5 "2019-05-20T14:18:58Z")

</div>

Hmm, makes sense.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/7/e748900f98752503529d0704a3d634abd62b7303.png)

Is there a way to fix this if we do not control the application that sends such timestamps?  
I guess only the condition at the end of your config:

```
if [tags] =~ /true/{
	mutate {
		gsub => [
		"last_seen", "31.03.2019 02:", "31.03.2019 03:"
		]
	}
}
```

---

<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:** [June 17, 2019, 2:19pm UTC](https://discuss.elastic.co/t/date-parsing-problems/181843/6 "2019-06-17T14:19:14Z")

</div>

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