May 2005
Intermediate to advanced
352 pages
14h 39m
English
UNIX_TIMESTAMP( )
UNIX_TIMESTAMP([datetime])This function returns the number of seconds since the start of the Unix epoch (January 1, 1970, Greenwich Mean Time). Without a given time, this function will return the Unix time for the current date and time. Optionally, a date and time value (directly or by way of a column value) may be given for conversion to Unix time with this function.
SELECT UNIX_TIMESTAMP( )
AS 'Now',
UNIX_TIMESTAMP('2004-05-09 20:45:00')
AS 'Same Time';
+----------------+----------------+
| Now | Same Time |
+----------------+----------------+
| 1084153500 | 1084153500 |
+----------------+----------------+The first column uses the function to determine the Unix time for the moment that the statement was entered. The second column uses the same function to determine the Unix time for the same date and time provided in a usual, readable format.
Read now
Unlock full access