# Convert utc format to local time

**URL:** <https://discuss.elastic.co/t/convert-utc-format-to-local-time/164237>\
**Category:** Logstash\
**Created:** [January 15, 2019, 5:14am UTC](https://discuss.elastic.co/t/convert-utc-format-to-local-time/164237 "2019-01-15T05:14:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [January 15, 2019, 7:37am UTC](https://discuss.elastic.co/t/convert-utc-format-to-local-time/164237/3 "2019-01-15T07:37:33Z")

</div>

> [@admlko](#):
>
> init =\> 'require "time"'

thank you. I have tried as your said. Athough no exception happens, the 'snapTime' filed still retainutc format rather than my local time zone.  
The filter as follows:  
`
filter{
ruby{
init => 'require "time"'
code => "event.set('snapTime',Time.parse(event.get('snapTime')).localtime('+08:00'))"
}
}
`  
The rubydebug stdout as follows:  
{  
"snapTime" =\> 2019-01-10T02:39:12.000Z,  
"@version" =\> "1",  
"@timestamp" =\> 2019-01-15T07:22:59.390Z,  
"name" =\> "wangqh"  
}  
the field 'snapTime' still retain '2019-01-10T02:39:12.000Z' rather than '2019-01-10T10:39:12.000+08:00'

---

_[View the full topic](https://discuss.elastic.co/t/convert-utc-format-to-local-time/164237)._
