# Expression binding timer that counts up

**URL:** <https://forum.inductiveautomation.com/t/expression-binding-timer-that-counts-up/77381>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 3, 2023, 5:37pm UTC](https://forum.inductiveautomation.com/t/expression-binding-timer-that-counts-up/77381 "2023-08-03T17:37:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [August 3, 2023, 5:37pm UTC](https://forum.inductiveautomation.com/t/expression-binding-timer-that-counts-up/77381/1 "2023-08-03T17:37:56Z")

</div>

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)))))`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 3, 2023, 5:48pm UTC](https://forum.inductiveautomation.com/t/expression-binding-timer-that-counts-up/77381/2 "2023-08-03T17:48:09Z")

</div>

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

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

```

The expression transform would do the modulus and formatting:

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

```

---

<div class="post-metadata">

**Author:** ![pbg](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pbg](https://forum.inductiveautomation.com/u/pbg)\
**Post date:** [August 3, 2023, 6:15pm UTC](https://forum.inductiveautomation.com/t/expression-binding-timer-that-counts-up/77381/3 "2023-08-03T18:15:13Z")

</div>

I was getting this error on the transform,

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/87d707fbc85bd264a53d62cdeddde2bf9f71b78d.png)

I type casted the args and that seemed to work,

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

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/111962a2087f6632d3c8e8843f873de98113be0c.png)

Thank you!
