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
Parameter | Type | Required | Description |
---|---|---|---|
timestamp | TIMESTAMP | Yes | A 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