dashboard time series chart - UTC / local / Moment.js?

245 views
Skip to first unread message

Chuan Khoo

unread,
Apr 3, 2018, 11:58:17 AM4/3/18
to Node-RED
I'm having difficulty trying to get local time displayed on the dashboard. It refuses to plot any data with local time and sticks to UTC. My server is running off an ubuntu digitalocean droplet.

Playing around with custom Moment.js formats (say, using LTS or LT) in the node settings doesn't work.

Curiously, if I adopt a Z/ZZ format, no timezone offset is seen at all, which partly explains why it won't give me local time (because the chart / NR doesn't seem to know that there is a local time configured).

I have my server configured with a local timezone via timedatectl. My logs show the proper local time so that's good.

Can anyone help? If it matters, my NR installation has been running very well the past few months. Charts seemed to automatically detect client machines' local time and show it correctly. Only after setting timedatectl on my server did I begin to notice these issues.


Cheers
C

Mike Arney

unread,
Apr 5, 2018, 9:23:29 AM4/5/18
to Node-RED
I ran into the same problem with my dashboard. I had a lot of help with this in the following link:


Colin Law pointed out this:
It is good practice to save data in a database as UTC, so first check that you are doing this.

When I started sending UTC timestamp data to my database, my dashboard displayed the correct local timezone. I did not need to manually convert to local. I hope this helps!

Thanks,
Mike

Chuan Khoo

unread,
Apr 11, 2018, 7:32:06 AM4/11/18
to Node-RED
Thanks Mike for the link.

Somehow it all worked out. It was peculiar because I was simply sending, via a JS node, Date.now() which did pass along the correct UTC timestamp to the chart node.

What I reckon happened was that I changed the locale time in ubuntu while NR was running, and somehow that messed up the running chart nodes. Redoing those nodes resolved the problem.

On the plus side of things, this made me find out more about how moment.js works. All grist for the mill.


Cheers
Chuan
Reply all
Reply to author
Forward
0 new messages