Good morning all,
I use this function node in my flow to check when my device sent the last data.
var d = new Date();
var options = {year: 'numeric', month: '2-digit', day: '2-digit', hour: `2-digit`, minute: `2-digit`, second: `2-digit`};
var _resultDate = d.toLocaleDateString('en-US', options);
msg.payload = _resultDate;
return msg;
The output is in this format:
03/08/2023, 10:38:19 AM
Is it possible to adapt this function to this format:
08-03-2023 10:38u
TestFlow:
[{"id":"5f343f10e8cf0863","type":"debug","z":"bbde0b5a14e0d0bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2090,"y":120,"wires":[]},{"id":"ff71cffbbb0b2b46","type":"function","z":"bbde0b5a14e0d0bc","name":"Format Time","func":"var d = new Date();\nvar options = {year: 'numeric', month: '2-digit', day: '2-digit', hour: `2-digit`, minute: `2-digit`, second: `2-digit`};\nvar _resultDate = d.toLocaleDateString('en-US', options);\nmsg.payload = _resultDate;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1910,"y":120,"wires":[["5f343f10e8cf0863"]]},{"id":"e0e7d150ac885167","type":"inject","z":"bbde0b5a14e0d0bc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":1750,"y":120,"wires":[["ff71cffbbb0b2b46"]]}]
Kind regards,
Marco