StringFromTime() Function
- Last UpdatedMar 01, 2021
- 1 minute read
Converts a timestamp given in UTC time to local time and returns the result as a string. This function takes Daylight Saving Time into account.
Note: This function is equivalent to the StringFromGMTTimeToLocal() function.
Syntax
result = StringFromTime (timestamp, format)
Parameters
timestamp
The number of seconds that have passed since midnight of January 1, 1970 in the UTC time zone. A literal integer value, integer tagname, or integer expression.
format
Determines how the string result is shown. A literal integer value, integer tagname, or integer expression in the range from 1 to 5 with following meaning:
1 - Shows the date according to the format set in the Regional Settings of the local operating system
2 - Shows the time according to the format set in the Regional Settings of the local operating system
3 - Shows the date and time as a 24 character string (ddd mmm dd hh:mm:ss yyyy)
4 - Shows the day of the week in short form
5 - Shows the day of the week in long form
Example(s)
This example assumes that the time zone on the local node is Pacific Standard Time (PST, UTC-0800). The UTC time passed to the function is 12:00:00 AM on Friday, January 2, 1970. Since PST is 8 hours behind UTC, the function returns the following results.
This script returns "1/1/70"
StringFromTime(86400,1)
This script returns "04:00:00 PM"
StringFromTime(86400,2)
This script returns "Thu Jan 01 16:00:00 1970"
StringFromTime(86400,3)
This script returns "Thu"
StringFromTime(86400,4)
This script returns "Thursday"
StringFromTime(86400,5)