# Json date is not parsing to @timestamp

**URL:** <https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539>\
**Category:** Logstash\
**Created:** [April 23, 2020, 7:46pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539 "2020-04-23T19:46:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhupal\_Bobbadi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhupal_bobbadi/32/67007_2.png) [@Bhupal\_Bobbadi](https://discuss.elastic.co/u/Bhupal_Bobbadi)\
**Post date:** [April 23, 2020, 7:46pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539/1 "2020-04-23T19:46:58Z")

</div>

I'm new to logstash and I'm trying to index json data into Elastic search with logstash and my data has datetime field, and I'm trying to use that field as @timestamp but I could not parse it to the field. Any suggestions or corrections to my code will help. Thanks in advance.

the following is my simple test data and config.

```auto
 echo '{"ReportID": "764678", "Timestamp": "2020-04-23 18:02:21"}'| ./bin/logstash -e 'input { stdin{ } } filter { date { match => ["Timestamp", "yyyy-MM-dd HH.mm.ss", "ISO8601"] target="@timestamp" } } output { stdout { codec => rubydebug }}'

{"logstash.version"=>"7.6.2"}

The actual output:
{
    "@timestamp" => 2020-04-23T19:37:50.420Z,
      "@version" => "1",
       "message" => "{\"ReportID\": \"764678\", \"Timestamp\": \"2020-04-23 18:02:21\"}",
          "host" => "myserver.com"
}

Expected output:

{
    "@timestamp" => 2020-04-23T18:02:210Z,
      "@version" => "1",
       "message" => "{\"ReportID\": \"764678\", \"Timestamp\": \"2020-04-23 18:02:21\"}",
          "host" => "myserver.com"
}

```

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [April 23, 2020, 7:52pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539/2 "2020-04-23T19:52:11Z")

</div>

it is converting your timestamp to UTC.  
looks like you are one hour behind UTC

---

<div class="post-metadata">

**Author:** ![Bhupal\_Bobbadi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhupal_bobbadi/32/67007_2.png) [@Bhupal\_Bobbadi](https://discuss.elastic.co/u/Bhupal_Bobbadi)\
**Post date:** [April 23, 2020, 7:55pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539/3 "2020-04-23T19:55:54Z")

</div>

the actual output has UTC time but it is not converting from input date--please see the minutes and seconds part.

---

<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 23, 2020, 10:06pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539/4 "2020-04-23T22:06:58Z")

</div>

Try

```
json { source => "message" }
date { match => ["Timestamp", "YYYY-MM-dd HH:mm:ss"] }
```

---

<div class="post-metadata">

**Author:** ![Bhupal\_Bobbadi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhupal_bobbadi/32/67007_2.png) [@Bhupal\_Bobbadi](https://discuss.elastic.co/u/Bhupal_Bobbadi)\
**Post date:** [April 23, 2020, 10:42pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539/5 "2020-04-23T22:42:13Z")

</div>

> [@Badger](#):
>
> json { source =\> "message" } date { match =\> ["Timestamp", "YYYY-MM-dd HH:mm:ss"] }

Thank you Badger.  
json filter did fix the issue, I just need to adjust my date and format in my data.

the below is working command with date parsed to UTC.

```auto
 echo '{"ReportID": "764678", "Timestamp": "2020-04-23T10:02:21"}'| ./bin/logstash -e 'input { stdin{ codec => json } } filter { json { source => "message" } date { match => ["Timestamp", "ISO8601"] timezone=>"Etc/UTC"} } output { stdout { codec => rubydebug }}'

```

---

<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 21, 2020, 10:42pm UTC](https://discuss.elastic.co/t/json-date-is-not-parsing-to-timestamp/229539/6 "2020-05-21T22:42:17Z")

</div>

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