标签:array res UNC func else min time 精确 end
function timediff($begin_time,$end_time)
{
if($begin_time < $end_time){
$starttime = $begin_time;
$endtime = $end_time;
}
else{
$starttime = $end_time;
$endtime = $begin_time;
}
$timediff = $endtime-$starttime;
$days = intval($timediff/86400);
$remain = $timediff%86400;
$hours = intval($remain/3600);
$remain = $remain%3600;
$mins = intval($remain/60);
$secs = $remain%60;
$res = array(‘day‘ => $days, ‘hour‘ => $hours, ‘min‘ => $mins,‘sec‘ => $secs);
return $res;
}
$begin_time = strtotime(‘+4 day 5 hours 10 mins 5 seconds ‘);
$end_time = strtotime("now");
$res = timediff($begin_time,$end_time);
实现两个unix时间戳的差,并返回两个时间戳相差的天、小时、分、秒,精确到秒
标签:array res UNC func else min time 精确 end
原文地址:https://www.cnblogs.com/lsbaiwyl/p/9054874.html