PHP获取两个时间差

时间:2022-08-06 17:20:57
<?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."秒;

?>

 只是一点点的算法问题