# How to calculate future time

**URL:** https://discourse.nodered.org/t/how-to-calculate-future-time/44035
**Category:** Dashboard
**Created:** [12 April 2021 13:57 UTC](https://discourse.nodered.org/t/how-to-calculate-future-time/44035 "2021-04-12T13:57:41Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [12 April 2021 19:10 UTC](https://discourse.nodered.org/t/how-to-calculate-future-time/44035/5 "2021-04-12T19:10:59Z")

</div>

@PinPat Are you using node-RED v1.3 or above?  
If so, you could use the [day.js package](https://www.npmjs.com/package/dayjs) in a function node to both calculate the new time, and also format it to however you wish.  
Day.js is a very lightweight package (2kB) and [full docs are here](https://day.js.org/docs/en/installation/installation).

Example Flow for node-RED v1.3 or above only - _This will load the day.js package into node-RED's externalModules folder_

![dayjs](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/b/4b7c286f5871a63804901a58af6956c92e50ed4f.jpeg)

```auto
[{"id":"94c3a6b3.922108","type":"function","z":"b3b413d1.05b1b","name":"","func":"let now=dayjs().add(msg.payload, 'minutes');\nmsg.payload=(now.format(\"HH:mm:ss\"));\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"dayjs","module":"dayjs"}],"x":345,"y":1380,"wires":[["79269a6e.fa51e4"]]},{"id":"dadca7a6.ebc708","type":"inject","z":"b3b413d1.05b1b","name":"Add 30 mins","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30","payloadType":"num","x":170,"y":1380,"wires":[["94c3a6b3.922108"]]},{"id":"79269a6e.fa51e4","type":"debug","z":"b3b413d1.05b1b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":1380,"wires":[]},{"id":"e84043ba.b05da","type":"inject","z":"b3b413d1.05b1b","name":"Add 45 mins","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"45","payloadType":"num","x":170,"y":1420,"wires":[["94c3a6b3.922108"]]},{"id":"a470cd92.fd24c","type":"inject","z":"b3b413d1.05b1b","name":"Add 10 mins","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":170,"y":1340,"wires":[["94c3a6b3.922108"]]}]

```

---

_[View the full topic](https://discourse.nodered.org/t/how-to-calculate-future-time/44035)._
