# Logstash date format - Converting timestamp without timezone to timetamp with timezone

**URL:** <https://discuss.elastic.co/t/logstash-date-format-converting-timestamp-without-timezone-to-timetamp-with-timezone/257426>\
**Category:** Logstash\
**Created:** [December 2, 2020, 11:01pm UTC](https://discuss.elastic.co/t/logstash-date-format-converting-timestamp-without-timezone-to-timetamp-with-timezone/257426 "2020-12-02T23:01:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasoninmel](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jasoninmel](https://discuss.elastic.co/u/jasoninmel)\
**Post date:** [December 2, 2020, 11:01pm UTC](https://discuss.elastic.co/t/logstash-date-format-converting-timestamp-without-timezone-to-timetamp-with-timezone/257426/1 "2020-12-02T23:01:53Z")

</div>

I got an event timestamp field without timezone stored in Elasticsearch as follows;

> "open-date": "2016-05-28T00:00:00"

This time is in Australia/Melbourne timezone (AEDT/AEST).

I used the following filter to covert this to timestamp with timezone and specified the timezone;

> date {  
> match =\> ["open-date", "yyyy-MM-dd'T'HH:mm:ss"]  
> timezone =\> "Australia/Melbourne"  
> target =\> "open\_date\_timezone"  
> }

In rebuy rebug output I can see the following;

> "open\_date\_timezone" =\> 2016-05-27T14:00:00.000Z

I want it to be with timezone i.e +10 instead of 000Z. Is it possible to achieve this in Logstash?

I will be storing this in RDBMS and will be casting the string field to timestamptz format using following snippet in SQL.

> CAST (? AS timestamptz)

---

<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:** [December 2, 2020, 11:07pm UTC](https://discuss.elastic.co/t/logstash-date-format-converting-timestamp-without-timezone-to-timetamp-with-timezone/257426/2 "2020-12-02T23:07:26Z")

</div>

There are no double quotes around the value of [open\_date]. It is not a string, it is a Logstash::Timestamp object. Such objects are always in UTC. If you want it to be a string you can use mutate+convert to make it so

```
mutate { convert => { "date_open" => "string" } }

```

You could replace the trailing Z with +10

```
mutate { gsub => ["date_open", "Z$", "+10"] }

```

but that moves it in time. If you want the field to be in Australia/Melbourne just use the string you started with.

---

<div class="post-metadata">

**Author:** ![jasoninmel](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jasoninmel](https://discuss.elastic.co/u/jasoninmel)\
**Post date:** [December 3, 2020, 12:32am UTC](https://discuss.elastic.co/t/logstash-date-format-converting-timestamp-without-timezone-to-timetamp-with-timezone/257426/3 "2020-12-03T00:32:24Z")

</div>

Thank you very much @Badger for highlighting the problem with date object being treated as a string when used quotes. It turned out the time has been adjusted to UTC (DB timezone is set to UTC) making the timezone offset to be updated correctly to +00. It is my bad that I didn't notice the different in time.

---

<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:** [December 31, 2020, 12:32am UTC](https://discuss.elastic.co/t/logstash-date-format-converting-timestamp-without-timezone-to-timetamp-with-timezone/257426/4 "2020-12-31T00:32:35Z")

</div>

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