Note about “Timestamps”
Timestamps refer to values that can be compared between each other, do Time span calculations and so on. But their value does not readily correspond to seconds, days or any other meaningful value. To obtain an meaningful value from these “Timestamps” you should use the string conversion operations (AtoTs and TsToA).
To get the current time values you can use the following code:
Long Year, Month, Day, Hour, Minute, Second
string Date, TimeDate := GetDateStr //Formatted as “DD.MM.YYYY”
Time := TimeStr(GetTime) //Formatted as “hh:mm:ss”Year := StrToL(Substr(Date, 0,2))
Month := StrToL(Substr(Date, 3,2))
Day := StrToL(Substr(Date, 6,4))
Hour := StrToL(Substr(Time, 0,2))
Minute := StrToL(Substr(Time, 3,2))
Second := StrToL(Substr(Time, 6,2))
AToTs
| Declaration | double AToTs(string s) |
| Function | Returns the timestamp of the specified time. |
| Example | double ts ts := AToTs(’12:00:00, 01.01.2000′) |
GetDateStr
| Declaration | string GetDateStr |
| Function | The function returns a string with the current system date in the format “DD.MM.YYYY”. |
| Example | string d d := getdatestr |
GetNow
| Declaration | double GetNow |
| Function | Returns the timestamp of the current time. |
| Example | double ts ts := GetNow |
Gettime
| Declaration | long GetTime |
| Function | The function returns the seconds since midnight for the current time. |
| Example | long s s := gettime |
LocalTimeToUTC
| Declaration | double LocalTimeToUTC(double dftLocalTime) |
| Function | Converts the specified timestamp dftLocalTime from local time to UTC time. |
| Example | double dftUtcTime dftUtcTime := LocalTimeToUTC(GetNow) |
Settime
WARNING! this function does not work, unless the HMI is being run with elevated windows privileges! We do NOT recommend running the HMI in elevated Privileges
| Declaration | SetTime (long day, long month, long year, long hour, long minute, long second) |
| Function | Sets the current time. |
| Example | SetTime (31, 12, 2000, 23, 59, 00) |
TimeStr
| Declaration | string TimeStr (long seconds) |
| Function | The function calculates the time from the value seconds (seconds since midnight) and returns a string in time format (hh:mm:ss). |
| Example | string t t := timestr(36000) |
TsToA
| Declaration | string TsToA(double ts) |
| Function | Returns the time as a string of the specified timestamp. |
| Example | string s s := TsToA(GetNow) |
UTCToLocalTime
| Declaration | double UTCToLocalTimeToUTC(double dftUtcTime) |
| Function | Converts the specified timestamp dftUtcTime from UTC time to local time. |
| Example | double dftLocalTime dftLocalTime := UTCToLocalTime(GetNow) |
WeekDay
| Declaration | long WeekDay(string date) |
| Function | he function is calculated from the string date (TT. MM.YYYY) and returns a value between 0 (Sunday) and 6 (Saturday) |
| Example | long w w := weekday(31.01.1996) |
WeekOfYear
| Declaration | long WeekOfYear(double dftTimeStamp, long nFormat) |
| Function | The function calculates the corresponding calendar week from the timestamp dftTimeStamp. If format 0 is specified, the calculation is made according to DIN 1366. If specified for format 1, the calculation is based on the UK/US scheme. |
| Example | long nWeek nWeek := WeekOfYear(GetNow, 0) |

