TO_UNIXTIME

All functions > DATE_AND_TIME > TO_UNIXTIME

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

Syntax

TO_UNIXTIME(timestamp)
sql

Arguments

ParameterTypeRequiredDescription
timestampTIMESTAMPYesA TIMESTAMP value to convert

Returns

Unix timestamp as DECIMAL (seconds since epoch)

Notes

  • Converts TIMESTAMP to Unix epoch seconds
  • Returns seconds since January 1, 1970 00:00:00 UTC
  • Result is a DECIMAL to preserve sub-second precision
  • Useful for interoperability with systems using Unix timestamps
  • Inverse of FROM_UNIXTIME
Last update at: 2025/10/13 10:23:46