# Logstash parse date with custom timezone

**URL:** <https://discuss.elastic.co/t/logstash-parse-date-with-custom-timezone/37721>\
**Category:** Logstash\
**Created:** [December 21, 2015, 11:59pm UTC](https://discuss.elastic.co/t/logstash-parse-date-with-custom-timezone/37721 "2015-12-21T23:59:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spuder/32/44895_2.png) [@spuder](https://discuss.elastic.co/u/spuder)\
**Post date:** [December 21, 2015, 11:59pm UTC](https://discuss.elastic.co/t/logstash-parse-date-with-custom-timezone/37721/1 "2015-12-21T23:59:08Z")

</div>

I have logs that have a field "timestamp" with the following format

```
  { 
    "foo":"bar",
    "timeStamp":"2015/12/12 04:18:15.839Z"
  }

```

Logstash doesn't recognize this as a time, so it imports it as a string and gives it a new field @timestamp which represents when the log was imported, not created.

Trying to use 'date' filter to convert this into a joda time compatible syntax.

[http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html](http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html)

```
 filter {
 date {
   match => ["timeStamp","YYYY/MM/DD hh:mm:ss.SSSz"]
   timezone => "UTC"
 }
}

```

What would be the correct joda syntax for the following date?

2015/12/12 00:00:00.983Z

I've verified that none of the following work:

match =\> ["timeStamp","YYYY/MM/DD hh:mm:ss.SSSz"]  
match =\> ["timeStamp","YYYY/MM/DD hh:mm:ss.SSSZ"]  
match =\> ["timeStamp","YYYY/MM/DD hh:mm:ss.SSS"]

Since my logs are always in Zulu time. I've also tried treating the timezone as a literal letter 'Z', with no luck

match =\> ["timeStamp","YYYY/MM/DD hh:mm:ss.SSS'Z'"]

I'm not sure how else to parse the trailing timezone ("Z")

---

<div class="post-metadata">

**Author:** ![Joshua\_Rich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshua_rich/32/44953_2.png) [@Joshua\_Rich](https://discuss.elastic.co/u/Joshua_Rich)\
**Post date:** [December 22, 2015, 12:22am UTC](https://discuss.elastic.co/t/logstash-parse-date-with-custom-timezone/37721/2 "2015-12-22T00:22:07Z")

</div>

You need to use `dd` for day of month. `DD` is day of year (i.e. count since Jan 1).

---

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spuder/32/44895_2.png) [@spuder](https://discuss.elastic.co/u/spuder)\
**Post date:** [December 22, 2015, 1:31am UTC](https://discuss.elastic.co/t/logstash-parse-date-with-custom-timezone/37721/3 "2015-12-22T01:31:56Z")

</div>

Thanks, Here is what I ended up doing that worked. By converting the slashes to dashes, logstash recognized the input as a date.

```
  mutate {
    gsub => ["timeStamp", "/", "-"]
  }
  date {
    match => ["timeStamp" ,"ISO8601"]
  }
```

---

<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:** [July 6, 2017, 5:17am UTC](https://discuss.elastic.co/t/logstash-parse-date-with-custom-timezone/37721/4 "2017-07-06T05:17:38Z")

</div>


