# Date does not convert date/time string properly

**URL:** <https://discuss.elastic.co/t/date-does-not-convert-date-time-string-properly/109243>\
**Category:** Logstash\
**Created:** [November 27, 2017, 3:26pm UTC](https://discuss.elastic.co/t/date-does-not-convert-date-time-string-properly/109243 "2017-11-27T15:26:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgervais](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@pgervais](https://discuss.elastic.co/u/pgervais)\
**Post date:** [November 27, 2017, 3:26pm UTC](https://discuss.elastic.co/t/date-does-not-convert-date-time-string-properly/109243/1 "2017-11-27T15:26:12Z")

</div>

I have the following input date , time string as input:  
Date == 03OCT17  
Hour == 20  
Minute == 45  
These 3 fields are combined into a single string. "03OCT17:20:45". where the timezone is

```
mutate {
	add_field => { "timestamp" => "%{Obs Date}:%{Obs Hour}:45" }

```

}  
The date generated by mutate above is parsed as shown below:  
date {  
match =\> ["timestamp", "ddMMMyy:HH:m"]  
target =\> "@timestamp"  
}

Therefore , input string as seen by date parser is:  
"timestamp" =\> "03OCT17:20:45",  
Output result is :  
"@timestamp" =\> 2017-10-04T00:45:00.000Z,  
"1) Why is the day wrong in the "@timestamp" . It is shown as 04 instead of 03.  
2) Why is the hour wrong in the "@timestamp". It is shown as T00 instead of T20  
I have tried this using timezone of -5:00 and still don't get the right day/hour.  
There is no dateparseerror output.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 28, 2017, 6:35am UTC](https://discuss.elastic.co/t/date-does-not-convert-date-time-string-properly/109243/2 "2017-11-28T06:35:01Z")

</div>

The `@timestamp` field is UTC. Presumably your local timezone is UTC-4 so 2017-10-03T20:45-0400 is correctly converted to 2017-10-04T00:45+0000.

---

<div class="post-metadata">

**Author:** ![pgervais](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@pgervais](https://discuss.elastic.co/u/pgervais)\
**Post date:** [November 28, 2017, 12:38pm UTC](https://discuss.elastic.co/t/date-does-not-convert-date-time-string-properly/109243/3 "2017-11-28T12:38:52Z")

</div>

Thanks Magnus.

---

<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:** [December 26, 2017, 12:38pm UTC](https://discuss.elastic.co/t/date-does-not-convert-date-time-string-properly/109243/4 "2017-12-26T12:38:54Z")

</div>

Closed on December 26, 2017, 12:38pm UTC

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