UNIX_TIMESTAMP
Returns the Unix time representation of the input (DATE, TIMESTAMP, or timestamp string) or the current time if no input is provided. Unix time is the number of seconds since (or before) the Unix epoch (1970-01-01 00:00:00 UTC).
Syntax
UNIX_TIMESTAMP() → int64
Examples
UNIX_TIMESTAMP exampleSELECT UNIX_TIMESTAMP()
-- 1624928208
UNIX_TIMESTAMP(date_timestamp_expression varchar) → int64
- date_timestamp_expression: The timestamp to convert to Unix timestamp. The expected format is
YYYY-MM-DD HH24:MM:SSwhere HH can be a value 1-24.
Examples
UNIX_TIMESTAMP exampleSELECT UNIX_TIMESTAMP('2021-12-22 13:44:11')
-- 1640180651
UNIX_TIMESTAMP(date_timestamp_expression varchar [, format varchar]) → int64
- date_timestamp_expression: The
DATEorTIMESTAMPstring to convert to Unix time. - format (optional): Specify the format of the time, date, or timestamp parameter, such as
YY-MM-DDorHH:MM:SS.
Examples
UNIX_TIMESTAMP exampleSELECT UNIX_TIMESTAMP('21-12-22', 'YY-MM-DD')
-- 1640131200
SELECT UNIX_TIMESTAMP('03/15/2026', 'MM/DD/YYYY')
-- 1773532800
SELECT UNIX_TIMESTAMP('03/15/2026 14:30:00', 'MM/DD/YYYY HH24:MI:SS')
-- 1773585000