FormatTime
The FormatTime function produces a string that formats a timestamp in the manner specified.
Syntax
FormatTime( time, format )
Remarks
The time parameter is the timestamp to be formatted. The format specifies how the timestamp is formatted. Note that in most cases the format will be a literal string, and, therefore, must be enclosed in quotes and preceded by a $.
The function will expand the following sequences based upon values calculated from the timestamp:
%a Abbreviated weekday name according to locale.
%A Full weekday name according to locale.
%b Abbreviated month name according to locale.
%B Full month name according to locale.
%c Local date and time representation (short date, system default).
%#c Local date and time representation (long date, system default).
%d Day of month. Uses two spaces. Right Justified. Padded with zero.
%H Hours into the day. Uses two spaces. Right Justified. Padded with zero.
%#H Same as %H with the exception that if both the hour and minute are zero, the hour will be reported as 24 on the previous day.
%I Hour with 12 hour clock. Uses two spaces. Right Justified. Padded with zero.
%j Day of year. Uses three spaces. Right Justified. Padded with zero.
%J Julian Date.
%m Numeric month. Uses two spaces. Right Justified. Padded with zero.
%M Minutes into the hour. Uses two spaces. Right Justified. Padded with zero.
%p Local equivalent of AM / PM designator.
%S Seconds into the minute. Uses two spaces. Right Justified. Padded with zero.
%U Week number of the year. (Sunday being the first day of the week.)
%w Day of week as an integer. Uses one space. Sunday = 0, Monday = 1, etc.
%W Week number of the year. (Monday being the first day of the week.)
%y Years into century. Uses two spaces. Right Justified. Padded with zero.
%Y Year as an integer.
%1 Tenths of seconds. Uses one space.
%2 Hundredths of seconds. Uses two spaces. Right Justified. Padded with zero.
%3 Thousandths of seconds. Uses three spaces. Right Justified. Padded with zero.
%4 1/10000 of second. Uses four spaces. Right Justified. Padded with zero.
%5 1/100000 of second. Uses five spaces. Right Justified. Padded with zero.
%6 Microseconds. Uses six spaces. Right Justified. Padded with zero.
%7 1/10000000 of second. Uses seven spaces. Right Justified. Padded with zero.
%8 1/100000000 of second. Uses eight spaces. Right Justified. Padded with zero.
%9 Nanoseconds. Uses nine spaces. Right Justified. Padded with zero.
%x Prints the subsecond resolution of the time stamp with a preceding period, no padding.
%X Local time representation.
%n Local date representation.
%Z Time zone name.
%% Displays the '%' character.
Values are right-justified and padded with one or more zeros where necessary.
All other characters in the format string will be transferred directory to the output.
NOTE: When viewing a project using the CSI Web Server, different browsers display the Short and Long System Defaults differently.
Examples
The following example outputs the timestamp in the "long" local format:
FormatTime(Timestamp("Server:CR1000.Test.AirTemp"),$"%#c")
The following example outputs the timestamp in the format:
9:47:15 AM on Mon, Aug 15, 2011 (day 227 of the year)
FormatTime(Timestamp("Server:CR1000.Test.AirTemp"),$"%X on %a, %b %d, %Y (day %j of the year)")