Issue
Provide a solution for displaying local server time
Product Line
EcoStruxure Building Operation
Environment
- Building Operation Automation Server
- Building Operation Enterprise Server
Cause
Request to display local server time
Resolution
Example code below can be inserted into a PE Script to allow display of local server time from within the workstation. By converting the time into a string the display of the information is not affected by any localization that is attempted by the client.
***************************
datetime output ServerTime, ClientDisplayTime
string output DisplayTimeString, DisplayTimeString2
String ampm
numeric h1, h2
numeric Adjustment
' Time Adjustment: UTC Offset, DayLight Savings Time
Adjustment = 4*3600
ServerTime = Time
'Set the desired Client Display Time
ClientDisplayTime = ServerTime + Adjustment
'Set String to ServerTime
print ServerTime to DisplayTimeString
h1 = TimePiece(hour, ServerTime)
if h1 = 24 then h1 = 12
if h1 > 12 then
h2 = h1-12
ampm = "PM"
else
h2 = h1
ampm = "AM"
Endif
print TimePiece(month, ServerTime);"/" ;~
TimePiece(dayofmonth, ServerTime);"/";~
TimePiece(year, ServerTime),~
h2;":"; ~
TimePiece(minute, ServerTime);":";~
TimePiece(second, ServerTime), ampm to DisplayTimeString2
****************************