Convert PHP Unix timestamp to MySQL datetime / MySQL time to PHP time convert function

PHP uses Unix Timestamp. While MySQL uses datetime format (YYYY-MM-DD HH-MM-SS) to store times. So, I’ve wriiten to easy functions to convert php timestamp to mySQL datetime format or vice versa!

// Converts SQL time to PHP Time Format

function time_sql2php($sqltime){
    return strtotime($sqltime . " GMT");

// Converts PHP time format to SQL Time Format

function time_php2sql($unixtime){
    return gmdate("Y-m-d H:i:s", $unixtime);