FROM_UNIXTIME()

All functions > DATE AND TIME > FROM_UNIXTIME()

Returns a timestamp from the given unix timestamp (BIGINT representation of the number of seconds since 1970-01-01 00:00:00 UTC).

Signatures

Returns: A TIMESTAMP value corresponding to the unix timestamp

FROM_UNIXTIME(unixtime: T) → TIMESTAMP
sql
ParameterTypeRequiredDescription
unixtimeTYesUnix timestamp in seconds since 1970-01-01 00:00:00 UTC

With:

  • T : Custom types: BIGINT | DECIMAL

Notes

  • Converts Unix epoch timestamp to TIMESTAMP
  • Input is seconds since January 1, 1970 00:00:00 UTC
  • Accepts BIGINT or DECIMAL values
  • Always returns UTC; compose with UTC_TO_LOCAL() to present a UTC-stored instant in a named zone
  • Casting the result to VARCHAR includes a UTC offset (1970-01-01 00:00:00+00). A TIMESTAMP literal casts without an offset. The two values still compare equal
  • Useful for converting Unix timestamps from external systems
  • Inverse of TO_UNIXTIME

Examples

FeatureQL
RETURN
    -- Convert Unix seconds to timestamp
    f1 := FROM_UNIXTIME(1710496200),
    -- Unix epoch
    f2 := FROM_UNIXTIME(0)
;
Result
f1 TIMESTAMPf2 TIMESTAMP
2024-03-15T09:50:001970-01-01T00:00:00