# Strftime is not working Logshtash ruby code

**URL:** https://discuss.elastic.co/t/strftime-is-not-working-logshtash-ruby-code/88008
**Category:** Logstash
**Created:** [June 2, 2017, 2:10am UTC](https://discuss.elastic.co/t/strftime-is-not-working-logshtash-ruby-code/88008 "2017-06-02T02:10:02Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)
#### Post date: [June 2, 2017, 10:43am UTC](https://discuss.elastic.co/t/strftime-is-not-working-logshtash-ruby-code/88008/3 "2017-06-02T10:43:27Z")

</div>

The LogStash::Timestamp class has a `time` method.

Try...

```auto
ruby {
code => "event.set('read_time' , event.get('@timestamp').time.strftime('%Y-%m'))"
}

```

---

_[View the full topic](https://discuss.elastic.co/t/strftime-is-not-working-logshtash-ruby-code/88008)._
