demo datetime

Decode time stamp to date time value

[{"id":"74112927.7fe318","type":"inject","z":"5eff65cb.2112dc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":172,"y":1298,"wires":[["ed5108af.074078","5c9041e.fb71ac"]]},{"id":"ed5108af.074078","type":"debug","z":"5eff65cb.2112dc","name":"","active":false,"console":"false","complete":"false","x":343,"y":1188,"wires":[]},{"id":"5c9041e.fb71ac","type":"function","z":"5eff65cb.2112dc","name":"","func":"msg.timestamp= new Date().toISOString()\nvar now     = new Date(); \nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds(); \nif(month.toString().length == 1) {\nvar month = '0'+month;\n}\nif(day.toString().length == 1) {\nvar day = '0'+day;\n}   \nif(hour.toString().length == 1) {\nvar hour = '0'+hour;\n}\nif(minute.toString().length == 1) {\nvar minute = '0'+minute;\n}\nif(second.toString().length == 1) {\nvar second = '0'+second;\n}   \nmsg.timestamp = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;\n\nmsg.payload=msg.timestamp;\nmsg2=[];\nmsg2.payload=\"test\";\n\nvar msg1 = { payload:\"first out of output 1\" };\nvar msg2 = { payload:year };\nvar msg3 = { payload:month };\nvar msg4 = { payload:day };\n\nvar msg5 = { payload:hour };\nvar msg6 = { payload:minute };\n\nreturn [  msg, msg2, msg3 , msg4,msg5,msg6 ];\n\n\n","outputs":"6","noerr":0,"x":305,"y":1312,"wires":[["ee9711b4.b46a2"],["f53a0795.d5d078"],["e4a04e4e.f9df7"],["e045add7.04c1c"],["d0b6d058.2c877"],["e750dfc1.6dcfe"]]},{"id":"ee9711b4.b46a2","type":"debug","z":"5eff65cb.2112dc","name":"","active":true,"console":"false","complete":"false","x":591,"y":1193,"wires":[]},{"id":"d0b6d058.2c877","type":"debug","z":"5eff65cb.2112dc","name":"","active":true,"console":"false","complete":"false","x":550,"y":1612,"wires":[]},{"id":"e750dfc1.6dcfe","type":"debug","z":"5eff65cb.2112dc","name":"","active":true,"console":"false","complete":"false","x":550,"y":1654,"wires":[]}]
suparit

Flow Info

created 1 year, 5 months ago

Node Types

Core
  • debug (x4)
  • function (x1)
  • inject (x1)

Tags

  • datetime
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option