util.Datetime.toSecondsSinceEpoch

Converts a datetime to a number of seconds since Epoch.

Syntax

util.Datetime.toSecondsSinceEpoch(
  local DATETIME q1 TO q2
 )
  RETURNING seconds FLOAT
  1. local is the local datetime value.
  2. seconds is the number of seconds since Epoch. Note that this is a FLOAT value as the source can be a DATETIME YEAR TO FRACTION(N).

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