# Node red time zones offset in Dashboard chart

**URL:** <https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469>\
**Category:** Dashboard\
**Created:** [2 March 2020 06:23 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469 "2020-03-02T06:23:14Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 12:00 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/21 "2020-03-02T12:00:55Z")

</div>

As you mentioned, your formatted date and time string is from `TZ Europe/London (GMT)`.

And you want convert to `GMT + 8` ?

What is doing the conversion to `GMT + 8` ? `chart.js` ?

Did you provide (already) a sample of the data you send to your `chart.js` function / node?

Since you already have the `unix timestamp`, you can just convert this to a formatted time string for `GMT + 8` and pass it on to your chart (I assume, without seeing the raw chart data).

There are two ways to do this.

The "right way" is to use some function code or node which will take the `unix timestamp` and convert this to a `GMT + 8` formatted time string.

The "wrong way" to do this is ... `<deleted>` 🙂

If you want, please provide some sample chart data which includes enough samples to understand the format of this chart data.

Did you provide this already and I missed it?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2020 12:11 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/22 "2020-03-02T12:11:54Z")

</div>

That isn't the correct unix time, for 1/1/2020 01:00:00 local time, it is the unix timestamp for 1/1/2020 01:00:00 UTC. So that is why the timestamp on the chart it wrong, it is expecting it to be given the timestamp in UTC, and it will display it in local time. Is the timestamp supposed to be the current time? If so the easiest way is probably to determine the timestamp in node-red, you can do this using

```auto
timestamp = Date.now().getUnixTime()

```

Then you should be able to feed that straight to the chart.

---

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 12:17 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/23 "2020-03-02T12:17:55Z")

</div>

Nevermind.... 🙂

Until I see the actual raw data going to `chart.js` showing the data and the times, I'm on the sidelines.

You are in good hands with @colin on this one!

---

<div class="post-metadata">

**Author:** ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)\
**Post date:** [2 March 2020 12:42 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/24 "2020-03-02T12:42:01Z")

</div>

Hello Colin, it gives me error on using  
Date.Now().getUnixTime()

Here is my code:

```auto
 var new_msg_target = {"x":new Date(time).getUnixTime(), "y": parseFloat(val)}

```

Error is:  
getUnitTime is not a function.

time variable holds the 1/1/2020 this kind of type of date format.  
Thanks !

---

<div class="post-metadata">

**Author:** ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)\
**Post date:** [2 March 2020 12:49 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/25 "2020-03-02T12:49:38Z")

</div>

Hello This code is working:

```auto
var new_msg_target = {"x":new Date(time.replace(' ', 'T')).getTime(), "y": parseFloat(val)}

```

Any suggestions/comments?

---

<div class="post-metadata">

**Author:** ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)\
**Post date:** [2 March 2020 13:24 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/26 "2020-03-02T13:24:28Z")

</div>

Dear All,

Thank you for all of your help. I found a way now on how to correct it, I just actually discovered that in Chart js, it can accept date format to be "yyyy-MM-dd HH:mm:ss", this is a 24 hour format like this: "2020-01-02 02:00:00" , so on the side of my .Net application I just need to format my time to be like that and node-red can understand it. no need to translate it on unix time. Don't know why I did not discovered it before.

Again, Thank you for all your support!

Regards

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2020 13:30 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/27 "2020-03-02T13:30:37Z")

</div>

> [@Colin](#):
>
> Date.now().getUnixTime()

Yes, sorry, getting my languages mixed up. It should be

```auto
{x: (new Date()).getTime()/1000, Y: ..}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 April 2020 13:30 UTC](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469/28 "2020-04-01T13:30:42Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/node-red-time-zones-offset-in-dashboard-chart/22469.md?page=1)
