SYS_TIME
Use the SYS_TIME script function to retrieve the current time. The script function returns the time at the beginning of script processing, and freezes that time for the rest of the processing.
Tip: Use SYS_TIME_PHYSICAL to retrieve the current time at the actual time of processing.
Syntax
SYS_TIME ([Time format][,Time Zone|UTC])
Parameters
-
SYS_TIME
Returns the current time at the start of processing -
Time format
(Optional) Time format for the retrieved date
For more information, see Date, Time and Period Formats in Scripts.
Format: script literal or script variable
Default: HHMMSS -
Time Zone or UTC
(Optional) Specifies the time zone for the time
Format: script literal or script variable
Allowed values:- Name of a Time Zone object
For more information, see Time Zone (TZ).
Format: script literal or script variable - UTC
Returns the time in UTC (Coordinated Universal Time)
- Name of a Time Zone object
Notes:
- The Time Zone defined in the object attributes applies, unless you specify a different Time Zone.
- If the object has no defined Time Zone, or if you specify a non-defined Time Zone object, then the Time Zone defined for the Client applies.
- The retrieved time remains the same, even when you use the script function multiple times within a script. Consistency is especially important when script processing is interrupted with a :WAIT script statement.
Important! When you use a :PUT_VAR script statement to transfer the current time to a VARA object that has the data type timestamp, the time can only be saved together with a date. Use one of the following combinations of date and time formats:
- YYMMDD HHMMSS (default)
- YYYYMMDD HHMMSS
- YYYY-MM-DD
Note: (Windows only) The format is not saved when the variable is stored on the Windows platform. The displayed date format is determined by the regional options defined in the control panel of Windows.
Examples
The following example determines the current time of day and stores the value in a script variable. The script uses a Time Zone object that is defined for Central European Time. The script prints the retrieved time in the activation report of the task.
:SET &TIME# = SYS_TIME("HH:MM:SS","TZ.CET")
:PRINT &TIME#
The following example specifies a time format that retrieves the seconds of the current time.
:SET &FORMAT# = "SS"
:SET &TIME# = SYS_TIME(&FORMAT#)
The following example does not specify a time format. The script uses the current time in the default HHMMSS format to define a condition.
:IF SYS_TIME()
= "120000"
!...
:ENDIF
The following example retrieves the current date and time, and uses the values to store an entry in a VARA object of timestamp data type. The script uses the default date and time formats.
:SET &DATE# = SYS_DATE()
:SET &TIME# = SYS_TIME()
:PUT_VAR ENTRY
DATE, , "&DATE# &TIME#"
See also: