util.Datetime.toSecondsSinceEpoch

Converts a date/time to a number of seconds since Epoch.

Syntax

util.Datetime.toSecondsSinceEpoch(
  t DATETIME q1 TO q2
 )
  RETURNS FLOAT
  1. t is the local datetime value.

Usage

The util.Datetime.toSecondsSinceEpoch() method converts the DATETIME value passed as parameter to a number of seconds since the UNIX® Epoch (1970-01-01 00:00:00 GMT)

Important:

The result is a whole number when the source is a DATETIME YEAR TO SECOND, but will be a floating point number when the source is a DATETIME YEAR TO FRACTION(N), to include the fractional part.

Example

IMPORT util
MAIN
    DEFINE sec INTEGER, loc DATETIME YEAR TO SECOND
    LET loc = CURRENT YEAR TO SECOND
    LET sec = util.Datetime.toSecondsSinceEpoch( loc )
    DISPLAY sec
END MAIN