Irrespective of the local timezone or daylight savings adjustment, the Agent always presents datetime as UTC unless a function is used to specifically convert to local time.
If you want to know the device's timezone, use the Agent.GetSummary method, which reports current TimeZone as an offset from UTC in minutes (positive or negative). If using TIMS, then you will need to restart TIMS to read any changes in timezone.
Agent methods return datetime columns as either
- UnixEpoch, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, which may be either SQL datatype integer or string
- IS0-8601 string YYYY-MM-DDTHH:MM:SSZ in which the timezone offset is always Z because Agent time is always presented in UTC.
Converting from Unix Epoch timestamp into readable formats
As previously stated, SQLite has many date and time functions, documented online at: https://sqlite.org/lang_datefunc.html. The Agent language also provides the EPOCHTOJSON function to convert a UnixEpoch integer to a IS0-8601 string. The example below shows how the SQLite functions STRFTIME and DATETIME could be used instead. It also shows these functions do not require the TS string to be CAST as an integer. Finally, the example also shows how DATETIME uses TimeZone.
The above example instruction will return something similar to the following in TIMS.
|1515972745||2018-01-14T23:32:25Z||2018-01-14 23:32:25||2018-01-14 18:32:25||2018-01-14T23:32:25Z||text||integer||-300|
Converting from readable format into Unix Epoch timestamp
Making data lists
When is now?
The examples above show how STRFTIME can tell you when an instruction was run, as UTC and adjusted to local time using TimeZone.
Sometimes it is useful for an instruction to know when it was originally sent, which may have been many moments before it was run. SCALE provides this with the following Environment variable:
UTC ISO-8601 compatible date time stamp of when the instruction was issued.
This is the timestamp of when the instruction was originally run and sent by the Tachyon Server. It remains the same if the same instruction is re-run.