PHP date functions such as strtotime() and time() and date() all return a value as a UNIX TIMESTAMP. This is great for date manipulation but becomes a problem when we need a date to INSERT into a MySQL database. The format of a MySQL TIMESTAMP is yyyy-mm-dd hh:mm:ss and to meet this need a simple PHP can be utilized to convert any UNIX TIMESTAMP into a MySQL TIMESTAMP.


 * @param int $timestamp
 * @return string
function unixToMySQL($timestamp)
date('Y-m-d H:i:s'$timestamp);

/*** example usage ***/
$time time();