Timezone in Debug window

I am doing something where I am recording into a global variable and showing in a debug window, the time/date of an event. In both places, it is showing it in Zulu format. Is there any way to get it to show using the server TZ instead?

I can't remember if it is the moment node that will do that for you.

It is almost always best to store timestamps in UTC and only convert when you display it. As @Trying_to_learn says you can use the moment node to do that or the numerous methods available for the JavaScript Date type.
Exactly what form are you saving the timestamp? For example it might be a string or JavaScript milliseconds ticks or as a js Date.

You can use Jsonata and moments to set TZ and format, as below

[{"id":"d2b5cc88.39646","type":"debug","z":"57675e72.26a0d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"$moment(payload).tz(\"london/europe\").format(\"YYYY-MM-DD HH:mm:ss\")","targetType":"jsonata","statusVal":"","statusType":"auto","x":280,"y":780,"wires":[]},{"id":"c0171d89.64b4f8","type":"inject","z":"57675e72.26a0d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2021-01-14T23:34:56.045Z","payloadType":"str","x":100,"y":780,"wires":[["d2b5cc88.39646"]]}]

Here is @Paul-Reed post on subject


The debug window will let you click on a javascript date object and it will rotate between a number and an ISO timestamp format. The ISO8601 format is ALWAYS in UTC. The reason for this is because this is how JavaScript converts from a Date object to JSON.

To avoid that, as others have said, you need to format it before output. A change node with JSONata gives you access to a moment class. The node-red-contrib-moment node lets you convert an input value in various formats to an output in various formats and also lets you add/subtract dates/times and change from one timezone to another. The moment class will also do this of course, and more, but you have to remember how to use it.

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