You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing training@inductiveautomation.com.
Version:
LESSON LIST
-
2:10Property Binding
-
1:37Property Binding – Bidirectional
-
3:01Expression Binding
Take Topic Challenge
Supplemental Videos
LESSON
Expression Binding – Format Date
Description
Learn how to format a date in an expression binding using the dateFormat and now functions.
Video recorded using: Ignition 8.1
Resources
Transcript
(open in window)[00:00] In this lesson, I'll demonstrate how to use an expression binding to format a date. I'll drag a label onto my Vision window and I'll create a binding on the text property. I want to not only return a date, but have it formatted a specific way so that it's easy for operators to read. I'll make this binding an expression. I can view the available expression functions by clicking the function button on the right. I'll go to the Date and Time category and then find the function dateFormat. This function will return a date formatted in whatever way I specify. You can see that the function takes two arguments, a date and a pattern. I'll go ahead and click the function and it'll get added to the expression. The first argument is the date that needs to be formatted. I want to display the current time, so I use the now function and return the current time. I'll go into the date and time functions and find it. Now takes one argument and it's the poll rate.
[01:05] I'll click the function to add it to my expression. The poll rate argument decides how often the date will be pulled or refreshed. It expects a number of milliseconds. I want this to refresh every second, so I'll put 1000. I have the date argument filled out, so I'll add a comma and move on to the format argument. I already have my format copied in my clipboard so I'll paste it into the expression. I'll add a link to our user manual page if you'd like to reference the date, format table, but I'll quickly explain my format. A capital M signifies the month, and since there's three M's, this is asking for a three letter abbreviation of the month. Next is the day, then the full year. Next we have the hour, which is in an AM/PM 12 hour format. Then we have the minutes, then the seconds, and finally the AM/PM marker. I'll add the closing parenthesis to finish the function and hit okay. Now I have a label on my window that retrieves the current date every second and formats it the way that I want.