# Logstash time stamp error

**URL:** https://discuss.elastic.co/t/logstash-time-stamp-error/75476
**Category:** Logstash
**Created:** [February 17, 2017, 11:23am UTC](https://discuss.elastic.co/t/logstash-time-stamp-error/75476 "2017-02-17T11:23:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sabyasachi\_mallick](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@sabyasachi\_mallick](https://discuss.elastic.co/u/sabyasachi_mallick)
#### Post date: [February 17, 2017, 11:23am UTC](https://discuss.elastic.co/t/logstash-time-stamp-error/75476/1 "2017-02-17T11:23:44Z")

</div>

my logstash in utc time zone.  
when it is loading data timestamp is in below format  
"@timestamp" =\> "2017-02-17T05:17:51.289Z",

but when i am just extracting date from @timestamp field with a ruby code as below  
tstamp = event['@timestamp'].to\_i  
event['date']=[Time.at](http://Time.at)(tstamp).strftime('%Y-%m-%d')

it should give me 2017-02-17 but it is giving me the 2017-02-16 date..  
not able to figure out why?

"date" =\> "2017-02-16"

---

<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: [February 18, 2017, 5:31pm UTC](https://discuss.elastic.co/t/logstash-time-stamp-error/75476/2 "2017-02-18T17:31:10Z")

</div>

It seems Ruby's Time class uses the local timezone by default. Perhaps you can use its getutc method to get a UTC timestamp?

---

<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 18, 2017, 5:31pm UTC](https://discuss.elastic.co/t/logstash-time-stamp-error/75476/3 "2017-03-18T17:31:19Z")

</div>

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