# How can I convert @timestamp from logstash to encoded format as YYYY-MM-DDThh:mm:ss.sss+/-hh:mm

**URL:** <https://discuss.elastic.co/t/how-can-i-convert-timestamp-from-logstash-to-encoded-format-as-yyyy-mm-ddthhss-sss-hh-mm/317608>\
**Category:** Logstash\
**Created:** [October 27, 2022, 11:28am UTC](https://discuss.elastic.co/t/how-can-i-convert-timestamp-from-logstash-to-encoded-format-as-yyyy-mm-ddthhss-sss-hh-mm/317608 "2022-10-27T11:28:17Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![teja\_tata](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@teja\_tata](https://discuss.elastic.co/u/teja_tata)\
**Post date:** [October 27, 2022, 5:53pm UTC](https://discuss.elastic.co/t/how-can-i-convert-timestamp-from-logstash-to-encoded-format-as-yyyy-mm-ddthhss-sss-hh-mm/317608/10 "2022-10-27T17:53:17Z")

</div>

I have also found one similar issue attaching code solution and link below.

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

```

> [@Date field being converted to timestamps](https://discuss.elastic.co/t/date-field-being-converted-to-timestamps/180044/3):
>
> Thanks for the reply. I though about change in it to string but couldnt do it, could you show me how? Also, so, there is no way to simple get my date values from the mysql and insert them just the way they are into es? Thanks a lot

But not sure how can I use this code to get the format I want [YYYY-MM-DDThh:mm:ss.sss+/-hh:mm]

---

_[View the full topic](https://discuss.elastic.co/t/how-can-i-convert-timestamp-from-logstash-to-encoded-format-as-yyyy-mm-ddthhss-sss-hh-mm/317608)._
