# Gateway Script timer

**URL:** <https://forum.inductiveautomation.com/t/gateway-script-timer/17548>\
**Category:** Ignition\
**Created:** [March 29, 2018, 10:15pm UTC](https://forum.inductiveautomation.com/t/gateway-script-timer/17548 "2018-03-29T22:15:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [March 29, 2018, 10:15pm UTC](https://forum.inductiveautomation.com/t/gateway-script-timer/17548/1 "2018-03-29T22:15:41Z")

</div>

How do you make a gateway script counter to count in seconds and write that time to a tag? I want the trigger for the counter to be on/off state of a multistate indicator.

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [March 29, 2018, 11:48pm UTC](https://forum.inductiveautomation.com/t/gateway-script-timer/17548/2 "2018-03-29T23:48:41Z")

</div>

You could have a boolean “enable” tag that is set by the multistate indicator. Then a “count” tag to store the seconds value. In a 1000 ms gateway timer script put the following:

```auto
if(system.tag.read("enable").value == 1):
	system.tag.write("count", system.tag.read("count").value + 1)

```

You will need to handle rollovers.

---

<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:** [March 30, 2018, 12:28am UTC](https://forum.inductiveautomation.com/t/gateway-script-timer/17548/3 "2018-03-30T00:28:13Z")

</div>

Consider recording start and stop timestamps to be precise. Something like [this thread](http://forum.inductiveautomation.com/t/timer-component/17125).
