# Print timestamp

**URL:** <https://forum.inductiveautomation.com/t/print-timestamp/56038>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [February 11, 2022, 3:09pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038 "2022-02-11T15:09:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexm](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@alexm](https://forum.inductiveautomation.com/u/alexm)\
**Post date:** [February 11, 2022, 3:09pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/1 "2022-02-11T15:09:39Z")

</div>

Hi,

I am trying to print date&time on a label every time I click on a button. I want the date&time to update only every time the button is being clicked,otherwise read the previous date&time that was printed. I have written this script:  
` self.custom.timestamp == dateFormat(now(0),"MMM d, h:mm a")`  
,on the onClick event of the button, hoping to print the date in a custom parameter of the button (called timestamp), that I could then read from a different text label.  
However it doesn’t seem to be working… any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 11, 2022, 3:20pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/2 "2022-02-11T15:20:28Z")

</div>

Please format any scirpts/code using the `preformatted text` button  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/3/0314f4da2bc6cf384419265e8cc78fa3fd991717.png)

The problem is you are using Ignition’s expression language in a script. You can just set the label’s text value to the time directly. Also, you should use the `onActionPerformed` event instead of `onClick`

```auto
now = system.date.now()
formattedDate = system.date.format(now,"MMM d, h:mm a")
self.getSibling("Label").props.text = formattedDate 

```

---

<div class="post-metadata">

**Author:** ![alexm](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@alexm](https://forum.inductiveautomation.com/u/alexm)\
**Post date:** [February 11, 2022, 3:23pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/3 "2022-02-11T15:23:52Z")

</div>

That worked thanks

---

<div class="post-metadata">

**Author:** ![alexm](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@alexm](https://forum.inductiveautomation.com/u/alexm)\
**Post date:** [February 11, 2022, 3:43pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/4 "2022-02-11T15:43:25Z")

</div>

During testing I see that every time I save the project the timestamps reset. Is there a way to avoid that?

Also if I change the perspective page and go back to it everything is erased as well.

Would that be a different time expression to get, perhaps from a database?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 11, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/5 "2022-02-11T15:50:31Z")

</div>

I believe that the project is updating the label’s value to what ever it is in the designer when you save it. Normally, I would say use client tags and bind them to the labels to make the data persist, but perspective doesn’t have client tags and I haven’t used perspective very much myself to know the best method for this.

---

<div class="post-metadata">

**Author:** ![alexm](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@alexm](https://forum.inductiveautomation.com/u/alexm)\
**Post date:** [February 11, 2022, 3:51pm UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/6 "2022-02-11T15:51:32Z")

</div>

Thanks for your reply. I will look into it

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [February 24, 2022, 12:45am UTC](https://forum.inductiveautomation.com/t/print-timestamp/56038/7 "2022-02-24T00:45:07Z")

</div>

There is a decent equivalent to client tags in Perspective. Perspective Customer Properties can be used to persist data through View changes.

Here is documentation on Session Custom Props: [Session Properties - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Session+Properties)
