The FormatDate() function converts a time that is specified in seconds and returns it as a date and time in a formatted string. Use this function when formatting dates (such as the current date string) for display to users, such as in the audit log for an asset. When using this function in an expression, keep in mind that this function returns a String.
This function has one required parameter, the timeInSeconds, and one optional parameter: dateFormat.
String FormatDate(Long timeInSeconds, String dateFormat)
where:
timeInSeconds - time for which you want to retrieve the formatted date string. If not specified with dateFormat parameter, the default format is applied to the string returned to this function: "yyMMdd hh:mm:ss" (for example, "100512 12:30:24").
dateFormat - optional; specifies the format for the corresponding timeInSeconds. For example, "yyyy/MM/dd hh:mm:ss "). If this parameter is not defined, the default format ("yyMMdd hh:mm:ss") is applied. Be careful to use the appropriate case for month (uppercase, MM) and minutes (lowercase, mm) and to enclose the date format in double quotation marks.
The following example determines if the data item, machineOn, is not equal to 1 (for example, the machine is off) and, if true, creates an audit log entry with the current date and time (returned by Now) formatted as "yyMMdd hh:mm:ss".
If: DataItem.machineOn.value!=1
Then: Audit("data-management", "Machine is off at " + FormatDate(Now(), "yyyy/MM/dd hh:mm:ss"))