$current_unix_time = time(); // get current Unix timestamp $mysql_datetime = date('Y-m-d H:i:s', $current_unix_time); // convert to MySQL datetime format echo $mysql_datetime; // output: 2021-09-20 14:30:00
$unix_time = 1632132300; // Unix timestamp for 20 September 2021, 14:30:00 $mysql_datetime = date('Y-m-d H:i:s', $unix_time); // convert to MySQL datetime format echo $mysql_datetime; // output: 2021-09-20 14:30:00
$unix_times = array(1632000000, 1632086400, 1632172800); // Unix timestamps for 19, 20, and 21 September 2021 $mysql_datetimes = array_map(function($unix_time) { return date('Y-m-d H:i:s', $unix_time); // convert each to MySQL datetime format }, $unix_times); print_r($mysql_datetimes); // output: Array ( [0] => 2021-09-19 00:00:00 [1] => 2021-09-20 00:00:00 [2] => 2021-09-21 00:00:00 )