Print timestamp


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?


Please format any scirpts/code using the preformatted text button

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

now =
formattedDate =,"MMM d, h:mm a")
self.getSibling("Label").props.text = formattedDate 
1 Like

That worked thanks

1 Like

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?

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.

Thanks for your reply. I will look into it

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