编程爱好者之家
/** * 获取两时间相差的天数小时以及秒 * $begin_time:开始时间 * $end_time :结束时间 **/ public function GetTimediff($begin_time,$end_time) { $starttime = null;$endtime=null; $begin_time = strtotime($begin_time); $end_time = strtotime($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; return [ "day" => $days, "hour" => $hours, "min" => $mins, "sec" => $secs ]; }