# Capture current date and time into a memory tag

**URL:** <https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936>\
**Category:** Ignition\
**Created:** [August 28, 2026, 1:32pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936 "2026-08-28T13:32:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 28, 2026, 1:32pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/1 "2026-08-28T13:32:51Z")

</div>

Is there a simple expression to move the current date and time into a memory tag? I just want a PLC bit to trigger a time capture. I see there is something called now() and I can trigger that to happen but since an if statement needs a false condition, I'm trying to copy that now() into another memory tag and it isn't work. There has to be an easy way to do this.

---

<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:** [August 28, 2026, 1:34pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/2 "2026-08-28T13:34:10Z")

</div>

> [@dfox37](#):
>
> PLC bit to trigger

Gateway tag change event that points at the trigger bit in question, write the value of `system.date.now()` to the appropriate storage tag.

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 28, 2026, 1:35pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/3 "2026-08-28T13:35:27Z")

</div>

Thanks Ryan, Any examples on how that's done? I've heard of scripts or expressions in the gateway itself but haven't done that yet. Thanks.

---

<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:** [August 28, 2026, 1:42pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/4 "2026-08-28T13:42:19Z")

</div>

> **[Tag Change Scripts​ - Gateway Event Scripts | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.3/platform/scripting/scripting-in-ignition/gateway-event-scripts#tag-change-scripts)**
>
> Gateway Event Scripts are scripts that run directly on the Gateway. They are useful because they always run, regardless if any Sessions or Clients are open. They also provide a guaranteed way to make sure only a single execution of a particular...

That manual link should cover basic setup of a gateway tag change event, it also has a link to a free video in there as well.

As for the script in the gateway tag change event, it would be something along the lines of

```python
# Catch rising edge of transition from false to true
if not previousValue.value and newValue.value:
    system.tag.writeBlocking(['Path/To/Storage/Tag'], [system.date.now()])

```

If you need this for multiple PLCs you can modify the script to build the path to the storage tag based on the path of the tag that triggered the event.

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 28, 2026, 3:51pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/5 "2026-08-28T15:51:17Z")

</div>

What does this mean:

Due to their nature, Client Tags will not trigger Gateway Tag Change Scripts. However, [Client Event Scripts](https://www.docs.inductiveautomation.com/docs/8.3/ignition-modules/vision/scripting-in-vision/client-event-scripts) enable you to trigger a script based on a Client Tag changing value.

Right now for testing I'm using a test bit in ignition not a plc bit and it doesn't seem to work. Am I doing it wrong or does it indeed need to be a plc tag?

---

<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:** [August 28, 2026, 4:10pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/6 "2026-08-28T16:10:03Z")

</div>

Client tags are specific to Vision Clients, and exist only on the client machine which is why they cannot trigger a Gateway Tag Change event.

What tag provider is your test tag listed under. If it's under `[Client]` then its in the wrong place.

It does not need to be a PLC tag, you can use a memory tag on your gateway. If possible show how your Gateway script and test tag are configured.

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 28, 2026, 5:26pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/7 "2026-08-28T17:26:31Z")

</div>

I'm using perspective and the default tag provider. I created a memory tag of type datetime and it doesn't matter what I try, it doesn't work. I tried your method, I tried putting a script on that tag itself under edit tag, I tried putting a script on the trigger tag. This is very frustrating so something that should be so simple.

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 28, 2026, 5:53pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/8 "2026-08-28T17:53:06Z")

</div>

In perspective a created a boolean memory tag and called it trigger. I also created a datetime memory tag and called it date. If I edit the trigger tag and go to scripting and value changed and type this:

```python
system.tag.writeBlocking(
    ["[default]date"],
    [system.date.now()]
)

```

Then it'll record the current date. However it'll record the date when the trigger is true and then again when the trigger is false. If I put an IF statement in front of that it won't fire at all. It doesn't matter what I use in the IF statement, the script just doesn't fire.

---

<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:** [August 28, 2026, 5:57pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/9 "2026-08-28T17:57:12Z")

</div>

> [@dfox37](#):
>
> In perspective

Irrelevant, tags exist outside of the modules, with the exception of Vision Client Tags

> [@dfox37](#):
>
> If I put an IF statement in front of that it won't fire at all.

Do you get an error in the logs with the `if` statement present? If so, what is the error that you get? What is the `if` statement you put in front of it?

> [@dfox37](#):
>
> If I edit the trigger tag and go to scripting

Wrong spot you need a **GATEWAY** Tag Change event

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/082498c203b7a3d4f776fd3324651124a92ec8f7.png)

Also, i just realized my `if` statement was using the wrong member for the latest value in a gateway tag change script, it should be `newValue.value` not `currentValue.value`. I have corrected my example

---

<div class="post-metadata">

**Author:** ![Nol](https://avatars.discourse-cdn.com/v4/letter/n/8e8cbc/32.png) [@Nol](https://forum.inductiveautomation.com/u/Nol)\
**Post date:** [August 28, 2026, 6:01pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/10 "2026-08-28T18:01:24Z")

</div>

> [@dfox37](#):
>
> If I put an IF statement in front of that it won't fire at all. It doesn't matter what I use in the IF statement, the script just doesn't fire.

Are you getting an error indicator on the side of the code? This works just fine as a tag change script that only fires on True and also good quality.

```python
if not initialChange and currentValue.quality.isGood() and currentValue.value:
    system.tag.writeBlocking(["[default]path/to/plcTime"], [system.date.now()])

```

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 28, 2026, 6:30pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/11 "2026-08-28T18:30:12Z")

</div>

Yes. As soon as I type the word if I get a little red tick mark on the right of the code. Again it doesn't matter if I write the script in the gateway or on the tag itself. So far the only somewhat luck I've had is the very basic script I pasted above. Which again isn't the answer I'm looking for but since I'm running out of hair to pull out, on the final product, I may just turn a plc bit on for a second or two. Then the final result will be a date and time that's off by a few seconds since the script will fire twice. A few seconds off on a several hour process should be acceptable.

---

<div class="post-metadata">

**Author:** ![Nol](https://avatars.discourse-cdn.com/v4/letter/n/8e8cbc/32.png) [@Nol](https://forum.inductiveautomation.com/u/Nol)\
**Post date:** [August 28, 2026, 6:39pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/12 "2026-08-28T18:39:14Z")

</div>

Hover over the red tick and it'll tell you the compile error. It appears when you type if because until the full If statement is written its invalid. If you're getting it with some of the supplied code here then most likely it's a missing indentation issue.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 28, 2026, 8:10pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/13 "2026-08-28T20:10:49Z")

</div>

There was a bug for event scripts:

> [@\[IGN-16691\]Gateway Event Script Compile Error](https://forum.inductiveautomation.com/t/ign-16691-gateway-event-script-compile-error/116115):
>
> I'm not sure if I'm crazy or what but I'm running into a compile error when trying to save a script for a Gateway Event. Crazy thing it I'm positive I was not getting this error running on 8.3.2. Then I upgraded to 8.3.7 and went into the script to add something and when I try to close & save I get a compile error. The other crazy thing is that I don't think I should be getting a compile error because the error is complaining about indent and my indent looks fine to me. Since the code is on t…

This was more of an annoyance than anything actually wrong. There was a workaround here:

> [@\[IGN-16691\]Gateway Event Script Compile Error](https://forum.inductiveautomation.com/t/ign-16691-gateway-event-script-compile-error/116115/5):
>
> I'm facing the same error after upgrading to 8.3.7 I've noticed that the issue is on the first indent/keyword. If you don't want to move your logic into libraries, another workaround is by adding triple-quoted string on first line. """""" and it let you save. I hope it gets fixed soon.

This is fixed in 8.3.9, released a few days ago.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 29, 2026, 12:23pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/14 "2026-08-29T12:23:41Z")

</div>

> [@dfox37](#):
>
> As soon as I type the word if I get a little red tick mark on the right of the code

This is actually normal. Because Python syntax requires a standard if statement have a `:` followed by a newline and a indented expression. So an if statement needs four things:

1. The keyword `if`
2. An expression which resolves to a boolean (`True` or `False`)
3. A `:`
4. An expression or group of expressions indented on a newline to be executed when the expression given as No. 2 evaluates as `True`

If you don't have all four of those things you should expect to see an error indicator. If you do have those things and you're seeing an error indicator thats a different issue.

> [@dfox37](#):
>
> but since an if statement needs a false condition

I'm not sure where you got this information, but this is just not the way it works. Perhaps you meant an if statement requires a value which will transition from false to true?

The example that @Nol gives shows the proper syntax, though it is written for a Tag Value Change script. For a Gateway Tag Change script it would look like:

```python
if not initalChange and newValue.quality.isGood() and newValue.value:
   system.tag.writeBlocking(["[default]path/to/plcTime"], [system.date.now()])

```

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 29, 2026, 5:49pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/15 "2026-08-29T17:49:28Z")

</div>

For testing today I'm using 8.1.48 and the above script worked. I will go back to 8.3.8 shortly and test. Another thought I had was maybe I can make the tag invisible when the PLC trigger is off. So I'll hold it on during the cycle and then when the cycle ends I'll turn it off. However I assumed wrong. Something simple like visibility expects a visible or hidden. As soon as I bind a tag to it, the value changes to true/false and it throws an error. Any ideas how to make a simple label hidden when the tag is false?

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 29, 2026, 5:53pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/16 "2026-08-29T17:53:43Z")

</div>

Nevermind, I saw style visibility and our good buddy chat had me looking through props, once I corrected chat, chat pointed me to meta. Guess this one is a meta tag. I got it to work.

---

<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:** [August 29, 2026, 5:58pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/17 "2026-08-29T17:58:36Z")

</div>

`Position.Display` property accepts true/false and is the normal way of toggling visibility in perspective. The meta property does hide it but it will still be taken into account when flex layout is computed, so it has its uses.

> **[Child Component Position Properties​ - Perspective - Flex Container | Ignition...](https://www.docs.inductiveautomation.com/docs/8.3/appendix/components/perspective-components/perspective-container-palette/perspective-flex-container#child-component-position-properties)**
>
> When a component is placed inside of a flex container, it will inherit the position properties listed below. | The Flex container provides an efficient way to lay out, align, and distribute space among components.

---

<div class="post-metadata">

**Author:** ![dfox37](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dfox37](https://forum.inductiveautomation.com/u/dfox37)\
**Post date:** [August 29, 2026, 6:14pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/18 "2026-08-29T18:14:06Z")

</div>

I tried adding display and Display to the position section and it threw an error. Am I in the wrong place?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 29, 2026, 6:22pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/19 "2026-08-29T18:22:45Z")

</div>

Have you watched any of the Inductive University videos?

I feel like perhaps we're mixing terminology between what is perspective animation expressions, and what is a Tag and scripting on a tag or the gateway.

A visibility animation in perspective (or vision for that matter) has nothing to do with a script (or expression) executing on a tag or tag event.

---

<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 29, 2026, 7:01pm UTC](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936/20 "2026-08-29T19:01:30Z")

</div>

> [@lrose](#):
>
> mixing terminology

💯

Indeed, tag events, whether on the tag or in a gateway project event, do not have direct access to user interface properties.

The recommended approach is to **bind** the tag to a property in the view or directly on the component, perhaps with an expression binding to directly drive the target property.

[Next page](https://forum.inductiveautomation.com/t/capture-current-date-and-time-into-a-memory-tag/116936.md?page=2)
