Name

UNIX_TIMESTAMP()

Synopsis

UNIX_TIMESTAMP([date])

If called without the optional date argument, this function returns the number of seconds since 1970-01-01 00:00:00 UTC as an unsigned integer. If the date parameter is passed, then the value returned is the number of seconds since the 1970 start date until the given date. This code will return the value 946684800 (the number of seconds up to the start of the new millennium) followed by a TIMESTAMP representing the current Unix time at the moment you run it:

SELECT UNIX_TIMESTAMP('2000-01-01');
SELECT UNIX_TIMESTAMP();

Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.