# Time in IST for log-rotation - Logstash

**URL:** <https://discuss.elastic.co/t/time-in-ist-for-log-rotation-logstash/211612>\
**Category:** Logstash\
**Created:** [December 12, 2019, 10:15am UTC](https://discuss.elastic.co/t/time-in-ist-for-log-rotation-logstash/211612 "2019-12-12T10:15:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)\
**Post date:** [December 12, 2019, 11:50am UTC](https://discuss.elastic.co/t/time-in-ist-for-log-rotation-logstash/211612/2 "2019-12-12T11:50:53Z")

</div>

HI

If what you want is to name your files using the date and time in your local time, you might try something like this:

```auto
filter {
  [... your stuff goes here...]
  ruby {
    code => "
      event.set('filename', event.get('@timestamp').time.localtime.strftime('%Y-%m-%d/%H'))
    "
  }
}
	
output {
  file {
    path => "/log/sync/ims-v1/%{filename}-ims.log"
  }
}	

```

Haven't tried this code but I use a similar construct to generate local time from `timestamp` (or from any date field).

Hope this helps.

---

_[View the full topic](https://discuss.elastic.co/t/time-in-ist-for-log-rotation-logstash/211612)._
