# Chronometer in perspective

**URL:** <https://forum.inductiveautomation.com/t/chronometer-in-perspective/79604>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [September 25, 2023, 7:38pm UTC](https://forum.inductiveautomation.com/t/chronometer-in-perspective/79604 "2023-09-25T19:38:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Gomez](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Miguel\_Gomez](https://forum.inductiveautomation.com/u/Miguel_Gomez)\
**Post date:** [September 25, 2023, 7:38pm UTC](https://forum.inductiveautomation.com/t/chronometer-in-perspective/79604/1 "2023-09-25T19:38:07Z")

</div>

Hello,

Just a Newbie question.

I need to see if a door is opened more than 5 minutes. When this time is reached the time elapsed have to be showed, so in other words, when a door is opened more than 5 minutes the counter appears in the screen showing the time elapsed so it is showed starting in 5 minutes.

The door is just a Boolean tag and I need when the value is 1 start counting. My problem is that I don't know how to get that elapsed time when the tag change.

I've been trying with not visible labels with text now(0) and now() trying the difference but I just receive an integer not a time elapsed

If you now how to do this I really appreciate you!

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 25, 2023, 7:48pm UTC](https://forum.inductiveautomation.com/t/chronometer-in-perspective/79604/2 "2023-09-25T19:48:29Z")

</div>

I would have a global memory tag that is the timestamp of when the door opened. You can have another tag with an expression along the lines of  
`max(0, dateDiff({[default]PathToDoorOpenTimestamp}, now(), 'second'))`.

From there you can then use the value of that expression tag to do additional formatting to get your time elapsed as HH:mm or mm or ss.

For your timer display, you can set an expression on the display property that is `{[Path]ToTimeElapsedTag}>300`, and then have that label display the formatted time elapsed value.

> [@Expression binding timer that counts up](https://forum.inductiveautomation.com/t/expression-binding-timer-that-counts-up/77381):
>
> 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…

should help some with figuring out how to get the seconds elapsed value into the format that you want

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 25, 2023, 7:56pm UTC](https://forum.inductiveautomation.com/t/chronometer-in-perspective/79604/3 "2023-09-25T19:56:17Z")

</div>

A very simple way for a non critical application is to calculate the time since the tag's timestamp last changed.

On your elapsed time label create a binding on the text property:

```auto
if({[default]DoorIsOpen}
  & now(1000) // Recalculate every 1000 ms
	- toMillis({[default]DoorIsOpen.Timestamp})
	> 8000, // 8 s for test purposes.
	(
		now(1000) // Recalculate every 1000 ms
		- toMillis({[default]DoorIsOpen.Timestamp})
	) / 1000, // Convert ms to s.
	"OK" // Will be displayed if door not open for more than 8 s.
)
``
```

---

<div class="post-metadata">

**Author:** ![Miguel\_Gomez](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Miguel\_Gomez](https://forum.inductiveautomation.com/u/Miguel_Gomez)\
**Post date:** [September 26, 2023, 5:59am UTC](https://forum.inductiveautomation.com/t/chronometer-in-perspective/79604/4 "2023-09-26T05:59:16Z")

</div>

Well Thank you all

I really Mix everything and the result was this:

```auto
if ({[default]DoorIsOpen.value} & now(1000)
-toMillis({[default]DoorIsOpen.Timestamp})>5000,
stringformat("%2d:%02d:%02d",toInt(floor(max(0,
datediff({[default]DoorIsOpen.Timestamp},now(),'seconds'))/3600)),toInt(floor (max (0,
 datediff({[default]DoorIsOpen.Timestamp},now(),'seconds'))/60)%60), toInt(max (0,
 datediff({[default]DoorIsOpen.Timestamp},now(),'seconds'))%60)), " ")

```

This shows Hours Minutes and seconds and it is showed 5 seconds after the door is opened

Thank you very much for your cooperation
