Issue
Timestamps in Script programs are different by an amount equal to the UTC offset of the workstation's timezone settings.
Product Line
EcoStruxure Building Operation
Environment
- Building Operation Enterprise Central
- Building Operation Enterprise Server
- Building Operation Automation Server Premium
- Building Operation Automation Server Bundled
- Building Operation Edge Server - Standard
- Building Operation WorkStation Script editor
Cause
Take the following program as an example:
Datetime Output TimeOut, TimeOut2
TimeOut = StrToDate ("1/17/2012 15:00")
TimeOut2 = StrToDate ("1/17/2012 3:00 PM")
In EcoStruxure Building Operation, the values will read: "1/17/2012 9:00:00 AM" (in this example, the UTC offset is set for -6).
In servers, all time values are stored in UTC, then the offset is applied by the client. When it receives a value from a Script program, it stores the value as UTC, then the offset for the selected timezone is applied.
Resolution
Write code in the Script program to adjust the time values to UTC.
Check the example code below to help understand operation:
Datetime Output dtOut1
Datetime Output dtOut2
String Output str1
dtOut1 = Date 'Local time, displays with added UTCOffset
dtOut2 = Date - UTCOffset - DST 'Local time, adjusted by the UTCOffset and DST, displays properly
Print Date to str1 'Local time String value displays properly
(UTCOffset system variable is available in v2.0 or higher, DST system variable is available in EBO 2022 v4.0 or higher)