Time left on timer - help with logic and calculations

Hi all,

I have a timer that I would like to “pause”. If I track the time that the is supposed to fire in a global in a rules file, I would like to be able to calculate the time left on the timer. Ie. if I want to pause the timer, I would calculate the remaining time on the timer using now and the datetime stored in the global and then I could use that value to restart the timer when required. I can’t figure out how to use the datetime functions to find the remaining time on the timer so I can restart it?

When creating the timer, save now.getMillis to a global var timerEnd.
When pausing the timer, save timerEnd - now.getMillis to a global var timerLeft
When restarting the timer, create the timer with now.plusMillis(timerLeft)

1 Like