# Date to CST

**URL:** <https://discuss.elastic.co/t/date-to-cst/169615>\
**Category:** Logstash\
**Created:** [February 22, 2019, 5:27pm UTC](https://discuss.elastic.co/t/date-to-cst/169615 "2019-02-22T17:27:34Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [February 22, 2019, 5:27pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/1 "2019-02-22T17:27:34Z")

</div>

I have date filed coming from db.  
"completed" =\> "04-12-2018 11:45:17"  
would like to convert to CST date field. I used following

date { match =\> ["completed", "dd-MM-YYY HH:mm:ss"]  
target =\> "completed"  
}

It becomes this  
"completed" =\> 2018-12-04T17:45:17.000Z

but it becomes different time. I know it is something to do it UTC and CST. I am in CST I need to change this to CST.  
how?

I try timezone=\>"CST", inside date filter but it gives me parse error.

---

<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:** [February 22, 2019, 5:38pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/2 "2019-02-22T17:38:27Z")

</div>

Try

```
 timezone => "Etc/GMT+4"

```

or Etc/GMT+6 or Etc/GMT-8, depending on which CST you are referring to. If you want daylight saving for central standard then another option would be CST6CDT.

---

<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:** [February 22, 2019, 5:59pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/3 "2019-02-22T17:59:43Z")

</div>

I just want to keep what ever the time it is. what is it converting ot

[root@test1]# echo "04-12-2018 11:45:17" | /usr/share/logstash/bin/logstash -f test.conf

{  
"@version" =\> "1",  
"completed" =\> 2018-12-04T17:45:17.000Z,  
"message" =\> "04-12-2018 11:45:17",  
"@timestamp" =\> 2019-02-22T17:44:23.267Z,  
}  
Difference is +6  
if I do etc/GMT-6 = 2018-12-04T05:45:17.000Z, ( 6 hour behind.)

I simply just want to keep whatever this time is.  
I am in "America/Chicago" timezone.

---

<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:** [February 22, 2019, 6:52pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/4 "2019-02-22T18:52:50Z")

</div>

All times in logstash and elasticsearch are stored as UTC, 05:45 in GMT+6 is 11:45 in UTC.

---

<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:** [February 22, 2019, 7:01pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/5 "2019-02-22T19:01:12Z")

</div>

Oh I am good now. just did test.

my input is 11:45 logstash convert it, to 17:45

kibana is also showing 11:45 --\> good so far.

now question is if I use this data on some other software lets say grafana, is it gone a show 17:45? or 11:45?

---

<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:** [February 22, 2019, 7:41pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/6 "2019-02-22T19:41:17Z")

</div>

Also added time difference. Putting it here so someone else can use it. Here is test config file

```
input { stdin { } }

filter {
  mutate {
add_field => {
     "completed" => "03-12-2018 12:29:38"
     "submitted" => "03-12-2018 11:29:38"
}
 }
  date {
match => ["submitted", "MM-dd-YYYY HH:mm:ss"]
target => "submitted"
  }
  date {
match => ["completed", "MM-dd-YYYY HH:mm:ss"]
target => "completed"
  }

ruby {
  init => "require 'time'"
  code => "event.set('time_complete_minutes',(event.get('completed')-event.get('submitted'))/60)"
}

}
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:** [March 22, 2019, 7:50pm UTC](https://discuss.elastic.co/t/date-to-cst/169615/7 "2019-03-22T19:50:30Z")

</div>

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