Mega Code Archive

 
Categories / MySQL Tutorial / Date Time Functions
 

FROM_UNIXTIME(unix_timestamp), FROM_UNIXTIME(unix_timestamp,format)

Returns a unix_timestamp argument as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. mysql> mysql> SELECT FROM_UNIXTIME(875996580); +--------------------------+ | FROM_UNIXTIME(875996580) | +--------------------------+ | 1997-10-04 13:23:00      | +--------------------------+ 1 row in set (0.00 sec) mysql> SELECT FROM_UNIXTIME(875996580) + 0; +------------------------------+ | FROM_UNIXTIME(875996580) + 0 | +------------------------------+ |        19971004132300.000000 | +------------------------------+ 1 row in set (0.00 sec) mysql> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),'%Y %D %M %h:%i:%s %x'); +--------------------------------------------------------+ | FROM_UNIXTIME(UNIX_TIMESTAMP(),'%Y %D %M %h:%i:%s %x') | +--------------------------------------------------------+ | 2007 22nd July 07:46:11 2007                           | +--------------------------------------------------------+ 1 row in set (0.00 sec) mysql>