# Date filter plugin doesn't take the timezone into account when using ISO8601

**URL:** <https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306>\
**Category:** Logstash\
**Created:** [September 3, 2021, 4:06pm UTC](https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306 "2021-09-03T16:06:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_E](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jose_e/32/47012_2.png) [@Jose\_E](https://discuss.elastic.co/u/Jose_E)\
**Post date:** [September 3, 2021, 4:06pm UTC](https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306/1 "2021-09-03T16:06:39Z")

</div>

Hi, I'm trying to normalize some timestamps into UTC from CEST, so far I've had no issues whatsoever except for when the parsed timestamp is already in ISO8601. At first, I wasn't sure whether the date-filter-plugin was working correctly so I tried the following:

```auto
mutate {
		add_field => { "timestamp" => "%{@timestamp}" }
		remove_field => ["@timestamp"]
	}

```

And for the date plugin I have this:

```auto
date {
        # timezone => "UTC"
        timezone => "Etc/GMT-2"
        target => "@timestamp"
        match => [
            "timestamp",
            "ISO8601"
        ]
        remove_field => ["timestamp"]
}

```

I'm parsing json logs directly and therefore I also parse the "@timestamp" as following:

```auto
{ "@timestamp": "2020-11-25T18:34:09.542Z"}

```

The resulting timestamp should be 2h behind the one parsed, but so far I'm getting the same timestamp (i.e: 2020-11-25T18:34:09.542Z).

Any idea if this is a bug or am I doing something wrong?

---

<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:** [September 3, 2021, 4:34pm UTC](https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306/2 "2021-09-03T16:34:12Z")

</div>

If the timezone is specified in the string you are trying to parse then you cannot override it using the timezone option.

The Z at the end of the string indicates it is in Zulu time, also known as UTC. If you think that Z should not be there then you can remove it using

```
mutate { gsub => ["timestamp", "Z$", ""] }
```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [September 3, 2021, 4:48pm UTC](https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306/3 "2021-09-03T16:48:37Z")

</div>

How does your original timestamp looks like? Can you share an example?

As badger said, if your original timestamp has an Z at the end, it is already in UTC and the timezone option from the `date` filter will do nothing.

If your timezone is in local time but wrongly has a Z at the end, then you can use the `gsub` provided to remove it.

---

<div class="post-metadata">

**Author:** ![Jose\_E](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jose_e/32/47012_2.png) [@Jose\_E](https://discuss.elastic.co/u/Jose_E)\
**Post date:** [September 6, 2021, 9:14am UTC](https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306/4 "2021-09-06T09:14:37Z")

</div>

Thank you very much to both of you. It was the Z thingy, I didn't realise it could cause this "issue" but it makes a lot of sense. I ended up using the gsub line and is all good now

---

<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:** [October 4, 2021, 9:14am UTC](https://discuss.elastic.co/t/date-filter-plugin-doesnt-take-the-timezone-into-account-when-using-iso8601/283306/5 "2021-10-04T09:14:46Z")

</div>

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