Expression binding timer that counts up

Hi, I want a timer that counts upwards in the format minutes:seconds where seconds counts to 60 then resets to 00, 01, 02 and so on and minutes counts on indefinitely. I use two params, a startTime and currentTime. Right now, the below works-ish, but I'd like to know if there is a way to format the numbers with a zero in front until 10 seconds as right now they simply go 1, 2, 3.

concat(tostr(toint(floor(dateDiff({view.custom.start},{view.custom.now},"minute")))),":", tostr(toint(floor(dateDiff({view.custom.start},{view.custom.now},"second") - (toint(floor(dateDiff({view.custom.start},{view.custom.now},"minute")))*60)))))

I'd use an expression binding with an expression transform. The binding would just compute seconds:

max(0, dateDiff({view.custom.start}, {view.custom.now}, "second"))

The expression transform would do the modulus and formatting:

stringFormat("%02d:%02d", {value} / 60, {value} % 60)
3 Likes

I was getting this error on the transform,

image

I type casted the args and that seemed to work,

stringFormat("%02d:%02d", toInt({value} / 60), toInt({value} % 60))

image

Thank you!

1 Like