# Date field being converted to timestamps

**URL:** <https://discuss.elastic.co/t/date-field-being-converted-to-timestamps/180044>\
**Category:** Logstash\
**Created:** [May 7, 2019, 6:28pm UTC](https://discuss.elastic.co/t/date-field-being-converted-to-timestamps/180044 "2019-05-07T18:28:52Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 7, 2019, 7:44pm UTC](https://discuss.elastic.co/t/date-field-being-converted-to-timestamps/180044/4 "2019-05-07T19:44:53Z")

</div>

event.get("@timestamp").to\_f returns the number of seconds since the epoch (.to\_f includes fractional seconds). You can format number of second since epoch as a date using strftime

```
    ruby {
        code => '
            t = Time.at(event.get("@timestamp").to_f)
            event.set("someField", t.strftime("%Y-%m-%d"))
        '
    }
```

---

_[View the full topic](https://discuss.elastic.co/t/date-field-being-converted-to-timestamps/180044)._
