# Change the Value of tag using time slicing

**URL:** <https://forum.inductiveautomation.com/t/change-the-value-of-tag-using-time-slicing/16418>\
**Category:** Ignition\
**Created:** [December 26, 2017, 6:10pm UTC](https://forum.inductiveautomation.com/t/change-the-value-of-tag-using-time-slicing/16418 "2017-12-26T18:10:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![k.jain](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@k.jain](https://forum.inductiveautomation.com/u/k.jain)\
**Post date:** [December 26, 2017, 6:10pm UTC](https://forum.inductiveautomation.com/t/change-the-value-of-tag-using-time-slicing/16418/1 "2017-12-26T18:10:00Z")

</div>

Hello,

I was wondering if there is a way of doing time slicing. I have a button and on action I want the current time saved in a memory tag and but clicking it again I want it to store the time stamp in another memory tag. I am trying to get the start and end times.

---

<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:** [December 26, 2017, 6:58pm UTC](https://forum.inductiveautomation.com/t/change-the-value-of-tag-using-time-slicing/16418/2 "2017-12-26T18:58:27Z")

</div>

In computer terms, “time slicing” is something else entirely. What you describe is more like a stopwatch function. Use a custom property on your button to hold a “Started” boolean. Your button’s action performed script would then be something like this:

```auto
if event.source.Started:
    system.tag.write('Path/To/End/Timestamp', system.date.now())
    event.source.Started = False
else:
    system.tag.write('Path/To/Start/Timestamp', system.date.now())
    event.source.Started = True

```

You can use this boolean to also drive styling of your button so it is obvious when the timer is running. If you need to be able to operate this setup from multiple clients, or with window open/close in between, create another tag in the gateway to hold the boolean and bind it bidirectionally to the custom property.
