Convert non-UTC timestamp to UTC

With all your answers, I think I have found a solution. I convert the non-UTC timestamp to a string, then I remove the TZ information at the end of the string, then I call the Date/Time Formatter of node-red-contrib-moment with input TZ = Luxembourg and output TZ = UTC, I then have a string with the correct UTC time then I can convert to a timestamp. In the flow below I try just before the DST time change and just after and it works well so this solution looks foolproof, correct :thinking:?

[{"id":"93ba06b.eb78ff8","type":"comment","z":"2833a284.9d380e","name":"Input = 1572145260000 = Non-UTC timestamp Europe/Luxembourg October 27, 2019 3:01:00 AM","info":"","x":370,"y":1259,"wires":[]},{"id":"1138185c.2c9428","type":"inject","z":"2833a284.9d380e","name":"","topic":"","payload":"1572145260000","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":141,"y":1314,"wires":[["671c4a57.d1f9d4"]]},{"id":"671c4a57.d1f9d4","type":"moment","z":"2833a284.9d380e","name":"","topic":"","input":"payload","inputType":"msg","inTz":"ETC/GMT","adjAmount":0,"adjType":"days","adjDir":"add","format":"","locale":"en_GB","output":"","outputType":"msg","outTz":"ETC/GMT","x":352,"y":1315,"wires":[["35d30c88.b8f7f4","696ea55f.a5f09c"]]},{"id":"35d30c88.b8f7f4","type":"debug","z":"2833a284.9d380e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":519,"y":1379,"wires":[]},{"id":"696ea55f.a5f09c","type":"string","z":"2833a284.9d380e","name":"","methods":[{"name":"delRightMost","params":[{"type":"str","value":"Z"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":540,"y":1315,"wires":[["52c27106.e2562","32aa7c54.d8c364"]]},{"id":"52c27106.e2562","type":"debug","z":"2833a284.9d380e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":719,"y":1379,"wires":[]},{"id":"32aa7c54.d8c364","type":"moment","z":"2833a284.9d380e","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Luxembourg","adjAmount":0,"adjType":"days","adjDir":"add","format":"date","locale":"en_GB","output":"","outputType":"msg","outTz":"ETC/GMT","x":725,"y":1316,"wires":[["e884868c.be6478","5bf0aba3.b10d84"]]},{"id":"e884868c.be6478","type":"debug","z":"2833a284.9d380e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":925,"y":1381,"wires":[]},{"id":"5bf0aba3.b10d84","type":"function","z":"2833a284.9d380e","name":"Timestamp","func":"var d = new Date(msg.payload);\nmsg.payload = d.getTime(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":1315,"wires":[["2ec533c4.accccc"]]},{"id":"2ec533c4.accccc","type":"debug","z":"2833a284.9d380e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1110,"y":1379,"wires":[]},{"id":"925e0962.c65888","type":"comment","z":"2833a284.9d380e","name":"Output = 1572141660000 = GMT October 27, 2019 2:01:00 AM","info":"","x":944,"y":1258,"wires":[]},{"id":"943d076d.bcaee8","type":"comment","z":"2833a284.9d380e","name":"Input = 1572145140 = Non-UTC timestamp Europe/Luxembourg October 27, 2019 2:59:00 AM","info":"","x":358,"y":1439,"wires":[]},{"id":"4272e3b9.45b5ec","type":"comment","z":"2833a284.9d380e","name":"Output = 1572137940000 = GMT October 27, 2019 12:59:00 AM","info":"","x":922,"y":1439,"wires":[]},{"id":"ca9eb40b.099a38","type":"inject","z":"2833a284.9d380e","name":"","topic":"","payload":"1572145140000","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":135,"y":1492,"wires":[["671c4a57.d1f9d4"]]}]
1 Like