Time

(Engine-Level Function)

Description: Returns a formatted string for a time of day.
Returns: Text
Usage: Script or steady state.
Function Groups: Time and Date
Related to: Date | Now | Seconds
Format: Time(Sec, TimeForm [, Flags, Locale])
Parameters:  
Sec
Required. Any numeric expression giving the number of seconds since mid night. The function, Now(1), is commonly used as it returns the current time of day, expressed in seconds.
TimeForm

Required. Any numeric expression giving the option for the time Time Codes (Predefined). Will also accept a time locale such as "us-en" matching the Windows locale.

If TimeForm is numeric, the format for the time will be interpreted.
If TimeForm is a text value that does not resolve to a numeric, it is interpreted as a time formatting string as follows.

String Example Description
h 9 Hours with no leading zero for single-digit hours. 12-hour clock.
hh 09 Hours with leading zero for single-digit hours. 12-hour clock.
H 21 Hours with no leading zero for single-digit hours. 24-hour clock.
HH 21 Hours with leading zero for single-digit hours. 24-hour clock.
m 7 Minutes with no leading zero for single-digit minutes.
mm 07 Minutes with leading zero for single-digit minutes.
s 12 Seconds with no leading zero for single-digit seconds.
ss 12 Seconds with leading zero for single-digit seconds.
f .1 Tenths of a second
ff .01 Hundredths of a second
fff .001 Milliseconds
t P One character time-marker string, such as A or P.
tt PM Multi-character time-marker string, such as AM or PM.

In the event that the TimeForm parameter does not resolve to either a numeric or text value, the system-configured time format, as specified through the Windows Control Panel, is used. In this case, the Flags parameter is used to select from a number of options for the time.

Flags
An optional parameter that is only used in the event that the TimeForm parameter does not resolve to a numeric or a text value. The Flags parameter may be set as follows to adjust the format of the date.

Value

Description

1

Do not generate minutes or seconds.

2

Generate minutes, but do not generate seconds.

8

Force 24-hour time format.

 The format string characters are case-sensitive. If you wish to include one of the formatting characters in your output string, then you must surround it with single quotation marks. For example, "h'h'" would display the current hour number in 12-hour clock format, with a lowercase h suffixed to it.

Locale
Optional text. May be used to specify a locale for which to format the time. Use Windows-standard locale strings, such as "en-us".
Comments: The Sec parameter may be negative, in which case it specifies the time before midnight. If greater than 86400, it specifies the time in the next day. The text string returned is at most 11 characters long.

Examples:

ZText(10, 10, Time(Now(1), 2), 0, 0);
time1 = Time(28800, 2);
time2 = Time(28800, 7);
time3 = Time(now(1), "m");

The first statement will display the current time in the upper right corner of the window in the form "08:24:13", and will update every second. The value of time1, time2, and time3 will not be displayed, but will be set to "08:24:00", "08:24 AM" , and "24" respectively.