# Time in logstash is getting different due to daylight saving time

**URL:** <https://discuss.elastic.co/t/time-in-logstash-is-getting-different-due-to-daylight-saving-time/268934>\
**Category:** Logstash\
**Created:** [March 31, 2021, 3:51pm UTC](https://discuss.elastic.co/t/time-in-logstash-is-getting-different-due-to-daylight-saving-time/268934 "2021-03-31T15:51:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjilinga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjilinga/32/86010_2.png) [@anjilinga](https://discuss.elastic.co/u/anjilinga)\
**Post date:** [March 31, 2021, 3:51pm UTC](https://discuss.elastic.co/t/time-in-logstash-is-getting-different-due-to-daylight-saving-time/268934/1 "2021-03-31T15:51:01Z")

</div>

Hi i am using ruby code in logstash as below and getting the time one hour less.  
ruby {  
code =\> "event.set('current\_window\_end', Time.now());"  
}

if current time is 10 :00 (in London) getting the time as 9:00. i have used below code to change the time but not woking.

date {  
match =\> ["current\_window\_end", "ISO8601"]  
timezone =\> "Europe/London"  
target =\> "current\_window\_end"  
}

can some one please help.

---

<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:** [March 31, 2021, 5:35pm UTC](https://discuss.elastic.co/t/time-in-logstash-is-getting-different-due-to-daylight-saving-time/268934/2 "2021-03-31T17:35:16Z")

</div>

It is unclear what result you want. Does this help?

```
    ruby {
        init => 'require "tzinfo"'
        code => '
            # Sadly Time.now.zone returns EDT, which Timezone.get does not understand
            tz = TZInfo::Timezone.get("US/Eastern")
            now = Time.now()
            event.set("now-utc", now)
            event.set("now-local", tz.utc_to_local(now))
        '
    }

```

produces

```
   "now-utc" => 2021-03-31T17:32:58.514Z,
 "now-local" => 2021-03-31T13:32:58.514Z
```

---

<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:** [April 28, 2021, 5:35pm UTC](https://discuss.elastic.co/t/time-in-logstash-is-getting-different-due-to-daylight-saving-time/268934/3 "2021-04-28T17:35:36Z")

</div>

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