You can simply break the string with a space character using the PHP function explode() -
$timestamp = "2012-10-19 18:19:56"; $splitTimeStamp = explode(" ",$timestamp); $date = $splitTimeStamp[0]; $time = $splitTimeStamp[1];
Another way to do this would be to use strtotime() in combination with date() -
$date = date('Ym-d',strtotime($timestamp)); $time = date('H:i:s',strtotime($timestamp));
source share