# UTC date in output filename

**URL:** <https://discuss.elastic.co/t/utc-date-in-output-filename/125790>\
**Category:** Logstash\
**Created:** [March 27, 2018, 4:40pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790 "2018-03-27T16:40:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milan\_Kaliraj](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Milan\_Kaliraj](https://discuss.elastic.co/u/Milan_Kaliraj)\
**Post date:** [March 27, 2018, 4:40pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790/1 "2018-03-27T16:40:32Z")

</div>

I am trying to save input date to a file in logstash. The output file has "%{+YYYYMMdd}" appended but this time is UTC time. How can i append file name on local time?

---

<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:** [March 27, 2018, 5:27pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790/2 "2018-03-27T17:27:26Z")

</div>

You'll have to use a ruby filter to create a field with the local time in whatever format you prefer. I suggest you place that field as a subfield of `@metadata` so that the field isn't included in the event sent to the output plugin. This has been discussed several times before and I think examples have been posted.

---

<div class="post-metadata">

**Author:** ![Milan\_Kaliraj](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Milan\_Kaliraj](https://discuss.elastic.co/u/Milan_Kaliraj)\
**Post date:** [March 27, 2018, 6:10pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790/3 "2018-03-27T18:10:21Z")

</div>

Thanks for instant reply. I am saving filenames in below format:

output {  
file {  
path =\> "LOG\_%{+yyyyMMddHH}"  
codec =\> line { format =\> "%{[message]}" }  
}

Can ruby filter change filenames "yyyyMMddHH" from UTC to local time?

---

<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:** [March 27, 2018, 6:22pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790/4 "2018-03-27T18:22:03Z")

</div>

Yes, and I have already described the general idea of how to do that.

---

<div class="post-metadata">

**Author:** ![Milan\_Kaliraj](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Milan\_Kaliraj](https://discuss.elastic.co/u/Milan_Kaliraj)\
**Post date:** [March 27, 2018, 6:22pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790/5 "2018-03-27T18:22:46Z")

</div>

thank you

---

<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:** [April 24, 2018, 6:22pm UTC](https://discuss.elastic.co/t/utc-date-in-output-filename/125790/6 "2018-04-24T18:22:58Z")

</div>

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