# Wrong Canvas timezone

**URL:** https://discuss.elastic.co/t/wrong-canvas-timezone/190221
**Category:** Kibana
**Tags:** canvas
**Created:** [July 12, 2019, 11:17am UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221 "2019-07-12T11:17:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)
#### Post date: [July 12, 2019, 11:17am UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/1 "2019-07-12T11:17:21Z")

</div>

I have created a line graph in canvas but in the time line I got a wrong timezone with the next SQL query:

SELECT HISTOGRAM("@timestamp", INTERVAL 1 MINUTES) Hora, ip\_origen, COUNT(ip\_origen) as Cont  
FROM autenticacion WHERE "@timestamp" \> NOW() - INTERVAL 10 MINUTES  
AND ip\_origen IS NOT NULL GROUP BY ip\_origen, Hora  
ORDER BY Hora

The preview is this:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/e/dedaca354a9f19817f3d3ffcf7fe0aa03cf62fc3.png)

As you can see the correct hour is 13:00 but in the graph there are 2 hours less:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/2/12a65cdf8c11c33c8074d2f138fcac067f0c9398.png)

I would like to know if there is a way to change the time zone, I have tried including tz="UTC+2" in the expression editor with no luck and I have readed something about moment.js but honestly I dont know what that is and I didnt find any tutorial.

Help me please!

---

<div class="post-metadata">

### Author: ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)
#### Post date: [July 12, 2019, 9:13pm UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/2 "2019-07-12T21:13:47Z")

</div>

Hey @dgonzalezp,

Unfortunately I think this is related to a bug we are tracking where Canvas isn't respecting Kibana settings for time zones. Here's the issue in github:

> <https://github.com/elastic/kibana/issues/33959>

---

<div class="post-metadata">

### Author: ![Catherine\_Liu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catherine_liu/32/34294_2.png) [@Catherine\_Liu](https://discuss.elastic.co/u/Catherine_Liu)
#### Post date: [July 12, 2019, 9:26pm UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/3 "2019-07-12T21:26:12Z")

</div>

In the interim while we're working on timezone support in Canvas, you can manually offset the time using this expression:

```auto
SELECT HISTOGRAM("@timestamp", INTERVAL 1 MINUTES) Hora, ip_origen, COUNT(ip_origen) as Cont
FROM autenticacion WHERE "@timestamp" > NOW() - INTERVAL 10 MINUTES
AND ip_origen IS NOT NULL GROUP BY ip_origen, Hora
ORDER BY Hora
| mapColumn "Hora" fn={getCell "Hora" | math "value + 1000*60*60*2"}
| alterColumn "Hora" type="date"

```

---

<div class="post-metadata">

### Author: ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)
#### Post date: [July 15, 2019, 7:04am UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/4 "2019-07-15T07:04:42Z")

</div>

Thanks for reply Catherine.  
I used the expression but I dont know why I recieved the next error message:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/3/938a510056099b6992fab105c86d732804f1213f.png)  
This is my expression editor code:

filters  
| essql  
query="SELECT HISTOGRAM(pruebafecha, INTERVAL 1 MINUTES) Hora, ip\_origen, COUNT(ip\_origen) as Cont  
FROM autenticacion WHERE pruebafecha \> NOW() - INTERVAL 10 MINUTES  
AND ip\_origen IS NOT NULL GROUP BY ip\_origen, Hora  
ORDER BY Hora"  
| pointseries x="Hora" y="mean(Cont)" color="ip\_origen"  
| plot defaultStyle={seriesStyle lines=3} yaxis=true  
font={font family="'Open Sans', Helvetica, Arial, sans-serif" size=14 align="left" color="#444444" weight="normal" underline=false italic=false} xaxis=true  
| render  
| mapColumn "Hora" fn={getCell "Hora" | math "value + 1000_60_60\*2"}  
| alterColumn "Hora" type="date"

---

<div class="post-metadata">

### Author: ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)
#### Post date: [July 15, 2019, 3:05pm UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/5 "2019-07-15T15:05:57Z")

</div>

@dgonzalezp The "| render" function should be after the bottom two expressions.

---

<div class="post-metadata">

### Author: ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)
#### Post date: [July 16, 2019, 6:09am UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/6 "2019-07-16T06:09:32Z")

</div>

Thanks for reply Tims

I did but still not working with the same error message:

"[mapColumn] \> Can not cast 'render' to any of 'datatable'"

---

<div class="post-metadata">

### Author: ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)
#### Post date: [July 18, 2019, 6:24am UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/7 "2019-07-18T06:24:17Z")

</div>

I have added 2 hours manually in the SQL query like this:

SELECT HISTOGRAM(pruebafecha **+ INTERVAL 2 HOURS** , INTERVAL 1 MINUTES) AS Hora, ip\_origen, COUNT(ip\_origen) as Cont  
FROM autenticacion WHERE pruebafecha \> NOW() - INTERVAL 1 HOURS  
AND ip\_origen IS NOT NULL GROUP BY ip\_origen, Hora  
ORDER BY Hora

It works but I dont know if this is the correct way to do it...

Thank you everyone for the help.

---

<div class="post-metadata">

### Author: ![tims](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tims/32/46750_2.png) [@tims](https://discuss.elastic.co/u/tims)
#### Post date: [July 19, 2019, 2:25pm UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/8 "2019-07-19T14:25:21Z")

</div>

Thanks for sharing your solution @dgonzalezp, yeah it looks like you are adding the 2 hours during the SQL query, versus Catherine's example would do it in the expression language. If it works then it works!

---

<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: [August 16, 2019, 2:25pm UTC](https://discuss.elastic.co/t/wrong-canvas-timezone/190221/9 "2019-08-16T14:25:32Z")

</div>

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