# Timer function that works gloabally(gateway)

**URL:** <https://forum.inductiveautomation.com/t/timer-function-that-works-gloabally-gateway/16849>\
**Category:** Ignition\
**Created:** [February 2, 2018, 2:55pm UTC](https://forum.inductiveautomation.com/t/timer-function-that-works-gloabally-gateway/16849 "2018-02-02T14:55:37Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [February 2, 2018, 3:28pm UTC](https://forum.inductiveautomation.com/t/timer-function-that-works-gloabally-gateway/16849/4 "2018-02-02T15:28:25Z")

</div>

I would suggest making a Tag with the type of ‘Date’ that stores the time of the last transition from 1-\>0.

Then in your Boolean tag, write a tag-changed event script that reads:

```auto
if previousValue.value == 1 and currentValue.value == 0:
    system.tag.write("Path_to_date_tag", system.date.now())
```

So now you’ve got the time of that change. In your vision window to display the duration to the user, in an expression binding do something like:

```auto
secondsBetween({datetag}, now())
```

Which will display the raw integer seconds since the last 1-\>0 change. You could format that into a string as you like.

---

_[View the full topic](https://forum.inductiveautomation.com/t/timer-function-that-works-gloabally-gateway/16849)._
