# Add time to current time Date/ Time formatter

**URL:** <https://discourse.nodered.org/t/add-time-to-current-time-date-time-formatter/63193>\
**Category:** General\
**Created:** [28 May 2022 17:25 UTC](https://discourse.nodered.org/t/add-time-to-current-time-date-time-formatter/63193 "2022-05-28T17:25:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![canedje](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/canedje/32/62281_2.png) [@canedje](https://discourse.nodered.org/u/canedje)\
**Post date:** [28 May 2022 17:25 UTC](https://discourse.nodered.org/t/add-time-to-current-time-date-time-formatter/63193/1 "2022-05-28T17:25:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 May 2022 18:26 UTC](https://discourse.nodered.org/t/add-time-to-current-time-date-time-formatter/63193/2 "2022-05-28T18:26:23Z")

</div>

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.

```auto
[{"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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 July 2022 18:26 UTC](https://discourse.nodered.org/t/add-time-to-current-time-date-time-formatter/63193/3 "2022-07-27T18:26:45Z")

</div>

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