Setting the timezone in Node-RED
Today I was strugling with the node red ‘time range switch’. I noticed it was switching at a different time I intended. After some research I came to the conclusion the timezone setting for Node RED was wrong even with the server timezone set correctly.
After figuring out the root cause setting the timezone in NodeRED solved the issue. To change the timezone in NodeRED add the following line to ‘settings.js’ (located in ‘$home/.node-red’):
1 | process.env.TZ = "Europe/Brussels"; |
a msg.payload = new Date().toLocaleString(); in a function should report it as per the server time
eg
Sun Sep 21 2014 20:31:23 GMT+0100 (BST)
Thanks @Peter! This solved the issue for me.