格式化方法
/**
* 根据秒返回时分秒,如33:03:02
* @param $seconds
* @return string
*/
function backHMSFromS($seconds)
{
if ($seconds >3600){
$hours =intval($seconds/3600);
$minutes = $seconds % 3600;
$time = ($hours < 10 ? "0" . $hours : $hours) .":".gmstrftime('%M:%S',$minutes);
}else{
$time = gmstrftime('%H:%M:%S',$seconds);
}
return $time;
}
得到时间差
$time = backHMSFromS(strtotime('now') - strtotime("2019-10-01 12:12:12"));