Get current time and time in 30/60/120mins in this format HH:MM(now)-HH:MM(future)

Hi guys,
I want to publish a value in this format HH:MM-HH:MM via MQTT. For example with 30 mins and a actual time of lets say 02:30 I want to have this payload: 02:30-03:10

What is the best way to do this?

I know it is possible with the function node… but I really don’t know how.

you can use JSONATA expressions for this. below is for 30 minutes and for timezone GMT+2

$now("[H#01]:[m01]", "+0200") & " - " & $fromMillis($millis() + 30*60000,"[H#01]:[m01]", "+0200")

timezone => "+0200" for GMT+2, change it for your location.
timedifference => 30*60000, 30 minutes times 60000 milliseconds.

above produces “15:16 - 15:46”

1 Like

Hm… i don’t understand to be honest. In which node do I have to use this go get the payload in this format?

The easiest would be to use a change node.
A “set” with msg.payload being what serkank gave you.
GV

1 Like

Thank you! That worked for me :slight_smile: