Node red time zones offset in Dashboard chart

Dear dashboard experts , I have a simple dashboard graph, but the node red shows timestamp in X axis to be offset by 8 hours, which my current time zone GMT + 8, for example the x-axis should be on 1 AM but it showing to be 9 am but the tooltip shows correct timestamp, how can I fix on the side of X axis?
Thanks in advance!

Are you adding data points in real time and letting node red automatically add the time stamps?
What OS are the machine running node red and the machine running the browser using?
What version of node red, nodejs and the dashboard are you using? You can get that information from the node red startup log.
It does seem odd that the tooltip and the chart annotation do not agree, can you post a screenshot showing that?

Hello kindly see attached file.
I actually sending data via UI template.
for example { x: 80918293829, y: 24}

Ok, so the tooltip and axis are showing the same actual time but the chart is is local time and the tooltip UTC (which is what the Z means), but both are wrong.
You haven't answered the other questions.

Hello Sorry for the incomplete answer

Here is the node-red version and dashboard version, I am running it unders Windows Server 2012 OS. my current time Region is in Singapore (GMT +8)

Thank you my friend. I hope you can help me.

Also what sort of chart is that? It doesn't look like a chart provided by the standard node red dashboard. Also data in the form { x: 80918293829, y: 24} is not valid for the standard chart as far as I can see.

Hello I actually created it in Template node. I am sorry about Dashboard chart, but I do believe it is something similar, I used Chart.js for this (same thing with dashboard charts), But as far as I remember, the same thing I get, if I have inputted timestamp on let say January 1, 2020 01:00:00 the X axis on dashboard chart will be on 9:am, it was offset 8 hours.

Hi Henjoe,

Perhaps not helpful, but I had a similar issue (with charts in the dashboard) recently and I solved it by adding moment and moment-timezone libs in settings.js and including / requiring them in my functions and adjusting TZ that way.

Something like this in settings.js

functionGlobalContext: {

and then using these libs in my functions.

I'm sure my way is "kludgy" (as it often is with my impatient and "quick to fix and move on'" nature (my bad, I know!),

Looking forward to learning a better way from the experts here, for sure!

This is therefore a chartjs question rather than a node-red question. My first bet would be that you are providing the timestamp in local time instead of UTC. If that is not it then probably you are providing it in UTC instead of local time.

Hello Collin, I actually providing the time via localtime. My question is.. Do I need to convert it on UTC?

Thanks for suggestion, but how do I install 'Moment'?
Is it via npm ? Many thanks ! Highly appreciated it.

If you want to convert your timestamp from UTC to local (or the reverse) you should not need to do use moment. How are you generating the timestamp?

Yes, I agree with Colin you should not need to install moment; but then again, I had trouble with the TZ information and, being impatient by nature, installed it as mentioned, and it worked for me.

AND yes, I installed moment and moment-timezone with npm just like you would any other node module, added it to the settings.js file and included it using the "node-red way", which works fine.

However, I would love to see this working well without moment and moment-timezone, but I could not get it to work as I wanted / needed until I installed and included it.

I'm sure it is not "best practice" for the NR gurus.... sorry about that. I'm not patient when things do not go as I expect after about 15 to 30 minutes of troubleshooting, and I move on to other solutions (my bad, I guess).

As you may notice, I am not religious about any technology, which does get me in trouble socially from time to time (lol, most of the time) with those who are more religious than me about a technical approach or a preferred solution.

Actually getting the data from a specific application this data has Value and timestamp field.
So assuming I have the data now (value and timestamp which is in GMT+8), If I had to convert the timestamp to UTC (GMT+0). for example:

Value: 25, timestamp: 2020-03-02 08:00:00 PM
so if I converted it on UTC
Value: 25, timestamp: 2020-03-02 12:00:00 PM

Am I right on this?
but If I will plot this to Chart/Trend it will show 8 PM on X-axis radther than 12 PM ?

Will it be unconventional way to do it ?

As I asked before, how are you generating the timestamp in the first place? You example had x: 80918293829. How are you calculating that?

I am using to get the data from an applications. I dont know if you are familiar with .Net applications but to make things simpler, after getting the timestamp from the applications I coverted it into unix time:

  Dim startTime As New DateTime(DateTime.Now.Year, 1, i, 0, 0, 0)
            uTime = (startTime - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds

Something like that, that uTime will be the variables for timestamp that I will fed on Chart.

Dear Henjoe,

I'm sure you know this already, but to repeat in case you may have forgotten (many people do); there is no local timezone information in a unix time stamp (epoch time).

So, when we convert from "unix time" (epoch time) to local time, of course we need TZ information; and when we convert from a formatted time string to "unix time" we also need TZ information.

Many people get confused because they think of "formatted time strings" as "time" but in fact, these strings are only "formatted local time strings". The underlying "time" is "unix time" which is the same everywhere in the world (there is no local TZ information in "unix time").

Anyway, I'm sure you remember this and my apologies for the reminder.

Hope this helps.

php > echo time();
1 Like

Hello my friend, I actually no idea on Z and TZ, I am just new to nodered, but many Thanks for your prompt answer, maybe I will charged this to experience :slight_smile:

Can you give us an example value of timestamp number that you are giving the chart, and what actual time that represents?

Hello with the code I have shared before, I get this value