Add time to current time Date/ Time formatter

Is it possible to add a time from msg.payload to the actual time in a Date/ time formatter node??
Used format HH:mm
For example: msg.payload is: 02.00
Current time is: 15:00
Result: 17:00

Have no idea whatthe date formatter node is.
You can add time to current and output in HH:mm format using the change node, with JSONata and $moment.add()
The difficult bit is formatting a number from your string input format.

[{"id":"bb052159.461c78","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"02.10","payloadType":"str","x":140,"y":1920,"wires":[["e7fcb7a2.fa502"]]},{"id":"e7fcb7a2.fa502","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment().add(\t   $sum(\t       $split($$.payload, \".\")#$i.($i=0 ? $number($)*60 : $number($))\t   )\t   ,\t   \"minutes\"\t).format(\"HH:mm\")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1920,"wires":[["93e51fcb.ead128"]]},{"id":"93e51fcb.ead128","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":1920,"wires":[]}]

expression

$moment().add(
   $sum(
       $split($$.payload, ".")#$i.($i=0 ? $number($)*60 : $number($))
   )
   ,
   "minutes"
).format("HH:mm")
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.