Hi,
I have a date time array, I use moment
node to convert the format and store the new value in the resulting array called arrLastModDate.
I use the split
node to split each element of the original date array to convert the format and the resulting array is also split
[{"id":"20258e8b.666432","type":"function","z":"42ca3d14.2c3124","name":"Get array date time","func":"var arrLastModDate = [];\n\narrLastModDate.push('2020-04-07T10:00:56.000Z');\narrLastModDate.push('2020-04-07T09:45:32.000Z');\narrLastModDate.push('2020-04-07T09:47:04.000Z');\narrLastModDate.push('2020-04-07T09:48:54.000Z');\narrLastModDate.push('2020-04-07T09:50:28.000Z');\n\nmsg.payload = arrLastModDate;\n\nreturn msg;","outputs":1,"noerr":0,"x":1350,"y":1940,"wires":[["3f8b4fa1.f7dbb"]]},{"id":"c45bf03c.6b6be","type":"inject","z":"42ca3d14.2c3124","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1190,"y":1940,"wires":[["20258e8b.666432"]]},{"id":"2b4b7b9f.3fa2c4","type":"split","z":"42ca3d14.2c3124","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1310,"y":2020,"wires":[["810bc72c.16e728"]]},{"id":"3f8b4fa1.f7dbb","type":"change","z":"42ca3d14.2c3124","name":"","rules":[{"t":"set","p":"arrUpdateDate","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1570,"y":1940,"wires":[["2b4b7b9f.3fa2c4"]]},{"id":"810bc72c.16e728","type":"moment","z":"42ca3d14.2c3124","name":"Convert format date time","topic":"","input":"payload","inputType":"msg","inTz":"Asia/Tokyo","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm:ss","locale":"ja_JP","output":"payload","outputType":"msg","outTz":"Asia/Tokyo","x":1490,"y":2020,"wires":[["153bdf58.60d591"]]},{"id":"153bdf58.60d591","type":"change","z":"42ca3d14.2c3124","name":"get msg.arrUpdateDate","rules":[{"t":"set","p":"arrUpdateDate","pt":"msg","to":"$append(arrUpdateDate, [payload])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1730,"y":2020,"wires":[["8224802c.a7801"]]},{"id":"8224802c.a7801","type":"debug","z":"42ca3d14.2c3124","name":"arrUpdateDate","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"arrUpdateDate","targetType":"msg","x":1740,"y":2100,"wires":[]}]
Can I use the split
node? Or do i use a loop
to convert the date format of each element of the original array?
Thanks!