Calculate Time with "plus x min" and "minus x min"

Hi there,

is there a possibility to calculate time in NodeRed comparable to what I can do in SQL with dateadd (min) ?
I have a time as a varchar ("23:59") and want to add one minute plus or minus - whenever I press a specific "+" or "-" button.

And I want it to jump automatically from 23:59 to 00:00

Is that possible ?

BG
Gawan

you should be able to use $moment in a change node using JSONata
e.g.

$moment($$.payload, "HH:mm").add(7, 'minutes').format("HH:mm")
All string and numeric inputs can be msg.properties. This can be done in a function node to.

More examples Search results for 'moment().add' - Node-RED Forum
Add - momentjs.com

You can also use Javascript date objects and setMinutes Date - JavaScript | MDN

1 Like

To do this in the front-end (if you needed to), you can use the JavaScript Date object.

It has the basic functions to convert.

Of course, you could also simply use an input box set to time input which will constrain input automatically to valid times.