util.Datetime.fromSecondsSinceEpoch() converts a number of seconds since Unix epoch to a DATETIME value.
Syntax
util.Datetime.fromSecondsSinceEpoch(seconds)
Parameters
seconds |
a number of seconds since Unix epoch to be converted (FLOAT) |
Usage and examples
util.Datetime.fromSecondsSinceEpoch() takes a FLOAT value showing the number of seconds since Unix epoch (1970-01-01 00:00:00 GMT) and converts it to a DATETIME value.
Unix epoch is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.
If the original value included
fractions of a second, then the returned result will be DATETIME YEAR
TO FRACTION(N).
Otherwise, it will be DATETIME YEAR TO SECOND.
example code #1
|
MAIN DEFINE dt DATETIME YEAR TO SECOND LET dt = util.Datetime.fromSecondsSinceEpoch(-1379020785) DISPLAY "Unix epoch time: -1379020785" DISPLAY "Human readable time: ", dt CALL fgl_getkey() END MAIN |
obtained results #1 |
|
example code #2 |
MAIN DEFINE dt1 DATETIME YEAR TO SECOND, dt2 DATETIME YEAR TO FRACTION(3) LET dt1 = util.Datetime.fromSecondsSinceEpoch(315630296) LET dt2 = util.Datetime.fromSecondsSinceEpoch(315630296.789) DISPLAY "Unix epoch time #1: 315630296" DISPLAY "Human readable time #1: ", dt1 DISPLAY "Unix epoch time #2: 315630296.789" DISPLAY "Human readable time #2: ", dt2 CALL fgl_getkey() END MAIN |
obtained results #2 |
|