传开始和结束格式时间,换算时间差
通过计算两个时间点,获取差距的年月日,时分秒
function getDifference($start,$end) { // $start = strtotime($start); // $end = strtotime($end); if ($start > $end){ $diff_time = $start-$end; }else{ $diff_time = $end-$start; } $year_t = 3600*24*365; $day_t = 3600*24; $hours_t = 3600; $minute_t = 60; $year = floor($diff_time/$year_t); $days = floor(($diff_time-$year*$year_t)/$day_t); $hours = floor(($diff_time-($year*$year_t)-($days*$day_t))/$hours_t); $minute = floor(($diff_time-($year*$year_t)-($days*$day_t)-$hours*$hours_t)/$minute_t); $seconds = $diff_time - $minute*$minute_t-$hours*$hours_t-$days*$day_t-$year*$year_t; //$minute = floor(); $arr = ['year'=>$year,'days'=>$days,'hours'=>$hours,'minute'=>$minute,'seconds'=>$seconds]; return $arr; }
希望大家共同进步,学习更多想学习的知识。