# Need to add timezone field to my output

**URL:** <https://discuss.elastic.co/t/need-to-add-timezone-field-to-my-output/38628>\
**Category:** Logstash\
**Created:** [January 7, 2016, 2:44pm UTC](https://discuss.elastic.co/t/need-to-add-timezone-field-to-my-output/38628 "2016-01-07T14:44:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![miko370](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@miko370](https://discuss.elastic.co/u/miko370)\
**Post date:** [January 7, 2016, 2:44pm UTC](https://discuss.elastic.co/t/need-to-add-timezone-field-to-my-output/38628/1 "2016-01-07T14:44:19Z")

</div>

Hi.

I need to add an extra field that will include the timezone of the local (LogStash agent) machine.  
I have tried using add\_field =\> {"TZ" =\> "%{+z}"} but it always give the UTC time.

Any way I can do that without specifying a fixed value (TZ =\> "Europe/Stockholm")?

---

<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:** [January 7, 2016, 3:09pm UTC](https://discuss.elastic.co/t/need-to-add-timezone-field-to-my-output/38628/2 "2016-01-07T15:09:38Z")

</div>

> I need to add an extra field that will include the timezone of the local (LogStash agent) machine.

I suspect you'll have to use a ruby filter. Assuming the timezone is in the TZ environment variable,

```auto
ruby {
  code => "event['TZ'] = ENV['TZ']"
}

```

should work. No, wait, there's also the [environment filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-environment.html).

> I have tried using add\_field =\> {"TZ" =\> "%{+z}"} but it always give the UTC time.

Yeah, because the `@timestamp` field is always UTC.

---

<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:16am UTC](https://discuss.elastic.co/t/need-to-add-timezone-field-to-my-output/38628/3 "2017-07-06T05:16:31Z")

</div>


