Timezone settings?

Hi,

I have a function which includes a line similar to this
new Date(1530215497000) (The epoch datestamp used here is an example)
and al though the server on which Node-red runs is set to the correct timezone, it is not respected and (since I’m in GMT +2) is consistently 2 hours off.

What am I missing here or what else can I do to fix this?

cheers

If you set the payload to that and pass it to a debug node what does it show and what do you expect it to show?
Please copy/paste the complete string it shows or paste a screenshot.

What server are you running on?
What version of node-red?
What version of nodejs?

Thanks!
It shows this 2018-06-29T08:57:30.000Z for new Date(1530262650000) and I would like it to say the correct time (as the Chrome console does when I run that same command) -> Fri Jun 29 2018 10:57:30 GMT+0200

Running on ARMBIAN 5.38 stable Debian, latest Node-Red en node is v8.11.3

This might help https://www.digitalocean.com/community/tutorials/understanding-date-and-time-in-javascript

What do you get from new Date()?

1 Like

Those two times are identical. The Z means it is showing it in UTC, the GMT+0200 means it is showing it in that timezone. It is just a matter of how you choose to display it, they are both the same time. If you want to display it on the dashboard (or elsewhere) in a particular or local timezone then you can use the Moment node to format it as you wish.

what does the command

dpkg-reconfigure tzdata

return?

A configuration utility. Set to Europe, Amsterdam.

Thanks. So Node-Red provides no local timezone functionalities itself then?

That is interesting, I would have expected the debug node output to display in local time of, I think, the server, but perhaps it is the browser. Are you running the browser on the same machine as node-red?

You can find more timezones here:
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones