12.5.5         clock

Description:   Obtain and manipulate time.

Syntax:         clock format clockValue ?-format string? ?-gmt boolean

 

Argument:     formatting options  

Returns:        Time

See Also:       WebAccess system tags (DAQ tags) %TTMDATE, %TTMTIME, %TTMMONTH,%TTMTIME, %TTMWDAY, %ATMHOUR, %ATMMDAY, %ATMMINUTE, %ATMMONTH, %ATMSECOND, %ATMWDAY, %ATMYDAY, %ATMYEAR

 

Examples:     

# example 1 - returns Mon Jan 07 13:46:35 Pacific
# Standard Time 2002

set time1 [clock seconds]

set displayt [clock format $time1]

SETVAL CONST_TEXT1=$displayt

 

# example 2 - returns " 13:54:52"

set time1 [clock seconds]

set displayt [clock format $time1 -format %T]

SETVAL CONST_TEXT1=$displayt

 

# example 3 - clock scan converts a time to seconds

# for example if %TMTIME = 16:57:45 on Sep 13 2004

# clockscantime = 1095119865  

# note that if no date is specified todays date is assumed

# the clockscan will wrap around days and months

set time1 [GETVAL %TTMTIME]

SETVAL "clockscantime=[clock scan $time1]"

 

# example 4 - clock seconds shows current time in seconds

# if screen script this is local time of client

SETVAL "seconds1=[clock seconds]"

set time2 [clock seconds]

 

# example 5 - clock format reformats the time. Here it is converted back to  HH:MM:SS format

SETVAL "minutes1=[clock format $time2 -format %H:%M:%S]"

 

WebAccess has it own clock and provides access to time using DAQ tags %TTMDATE, %TTMTIME, %TTMMONTH,%TTMTIME, %TTMWDAY, %ATMHOUR, %ATMMDAY, %ATMMINUTE, %ATMMONTH, %ATMSECOND, %ATMWDAY, %ATMYDAY, %ATMYEAR

Most user will want to use clock seconds to get the local time on the client or SCADA node.  Run from a screen script (local script), clock seconds returns the time on the client.  Run in a Global Script, it returns time on the SCADA node.  This will return the local time in seconds from a reference date (Queen Victoria's birthday or the Day Microsoft was incorporated or some other rumored landmark).  For example. on September 14, 2004 at 11:04:15 am clock seconds returns a value of 1095185055.

Most users will want to use clock scan to convert a text string into a format similar to clock seconds.  Use clock scan to compare a time to clock seconds.  For example, on Sept. 13 2004, [clock scan  16:57:45] returns a value of 1095119865.

Use clock format, to convert clock seconds into a traditional time format. For example, [clock format 1095119865 -format %H:%M:%S] returns a text string of 16:57:45.