# Ruby exception occurred: undefined method \`localtime'

**URL:** https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-localtime/48751
**Category:** Logstash
**Created:** [April 29, 2016, 12:45am UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-localtime/48751 "2016-04-29T00:45:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![stefansaye](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@stefansaye](https://discuss.elastic.co/u/stefansaye)
#### Post date: [April 29, 2016, 12:45am UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-localtime/48751/1 "2016-04-29T00:45:05Z")

</div>

hi all,

I am using logstash 2.1.3 ,I want to show the @timestamp field in my timezone, like "@timestamp" =\> "2015-03-09T04:24:29.718+08:00", I try to using ruby conversion in filter.

```
 filter {
    ruby {
           code => "event['@timestamp'] = event['@timestamp'].localtime('+08:00')"
    }
}

```

but i got the error msg as below,

> Ruby exception occurred: undefined method `localtime' for "2016-04-29T00:40:51.926Z":LogStash::Timestamp {:level=\>:error}

Any help is welcome to resolve this.

---

<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: [April 29, 2016, 5:33am UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-localtime/48751/2 "2016-04-29T05:33:39Z")

</div>

The `@timestamp` field is supposed to be UTC. To reduce future pain don't fight the system.

---

<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:00am UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-localtime/48751/3 "2017-07-06T05:00:02Z")

</div>


