# How to handle Daylight Savings Time in Kibana Canvas?

**URL:** https://discuss.elastic.co/t/how-to-handle-daylight-savings-time-in-kibana-canvas/254014
**Category:** Kibana
**Tags:** canvas
**Created:** [November 2, 2020, 10:42am UTC](https://discuss.elastic.co/t/how-to-handle-daylight-savings-time-in-kibana-canvas/254014 "2020-11-02T10:42:13Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![egray](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@egray](https://discuss.elastic.co/u/egray)
#### Post date: [November 2, 2020, 10:42am UTC](https://discuss.elastic.co/t/how-to-handle-daylight-savings-time-in-kibana-canvas/254014/1 "2020-11-02T10:42:13Z")

</div>

I am creating a Canvas with a visualization in Timelion. I am able to get accurate time buckets, and when I look at the `datatable` the graph is based on, I can see that @timestamp is being stored as local time with the correct offset. However, the x-axis will only display UTC times, and I can't simply use a fixed offset because of DST. My timezone in both Kibana settings and the `timelion` function is set to my region.

I've been able to hack this in `essql` by getting `DATEPART('tz', @timestamp)` and then doing a `mapColumn` to add this offset to @timestamp. However, my boss would really like a moving average , and it seems either very difficult or impossible to do this in Elasticsearch SQL. I have also tried saved visualisations but if I use a Canvas expression for the timerange, it automatically evaluates to a static timerange (or throws an error when I try to pipe it in).

Has anyone managed to handle this issue, and could I see your solution?

---

<div class="post-metadata">

### Author: ![egray](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@egray](https://discuss.elastic.co/u/egray)
#### Post date: [November 2, 2020, 11:42am UTC](https://discuss.elastic.co/t/how-to-handle-daylight-savings-time-in-kibana-canvas/254014/2 "2020-11-02T11:42:51Z")

</div>

Update: I solved this myself in an extremely hacky way. After the `timelion` function I put in this expression:

```auto
 | mapColumn "t" fn={getCell "@timestamp"
  | math {string
            "2*"
            {context}
            "-"
            {formatdate "YYYY-MM-DDTHH:mm:ss" | date {context}
          }}}
| alterColumn "t" type="date"

```

This takes advantage of Kibana's timezone setting. When I input a string to date it assumes that the date is in my local time (including timezone) and converts it to UTC. But if it's already in UTC, it sets the time back by the required offset, so I can get the offset by subtracting one value from the other. Then I add the offset to @timestamp. The 2\* is just a simplication of @timestamp + (@timestamp - (@timestamp - offset)).

---

<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: [November 30, 2020, 11:42am UTC](https://discuss.elastic.co/t/how-to-handle-daylight-savings-time-in-kibana-canvas/254014/3 "2020-11-30T11:42:51Z")

</div>

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