PHP获取两个时间差

<?php
//PHP计算两个时间差的方法 
$startdate="2017-12-3 12:00:00";
$enddate="2017-12-4 12:00:00";
$date=floor((strtotime($enddate)-strtotime($startdate))/86400);
$hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600);
$minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60);
$second=floor((strtotime($enddate)-strtotime($startdate))%86400%60);
echo $date."天";
echo $hour."小时";
echo $minute."分钟";
echo $second."秒;

?>

 只是一点点的算法问题

原文地址:https://www.cnblogs.com/chenrunxuan/p/7728210.html