$start_time = '2017-09-06 15:12:20';
$end_time = '2018-09-08 10:20:45';
get_time($start_time,$end_time);
function get_time($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();
echo $year.'年'.$days.'天'.$hours.'小时'.$minute.'分钟'.$seconds.'秒';
}
相关推荐
特别申明:本站的主旨在于收集互联网运营相关的干货知识,给运营小伙伴提供便利。
网站所收集到的公开内容均来自于互联网或用户投稿,并不代表本站认同其观点,
也不对网站内容的真实性负责,如有侵权,请联系站长删除