$start = "2015-01-01 10:00:00";
$end = "2015-05-05 12:06:06";
$x = strtotime($start);
$y = strtotime($end);
$z = abs($y - $x);
$days = floor($z/(60 * 60 * 24));
$years = floor($z/(365 * 60 * 60 * 24));
$months = floor(($z - $years * 365 * 60 * 60 * 24)/(30 * 60 * 60 * 24));
$days = floor(($z - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24)/(60 * 60 * 24));
$hours = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24)/(60 * 60));
$minuts = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24 - $hours * 60 * 60)/60);
$seconds = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24 - $hours * 60 * 60 - $minuts * 60));
输出是:如何找到两个日期之间的区别
4 month 4 days 1 hour 6 minute 6 seconds
预期成果是:
4 month 4 days 2 hour 6 minute 6 seconds
看看日期时间,对象和(日期时间 - >差异()](http://php.net/manual/en/datetime.diff.php)函数..顺便说一下,小时差异是正确的...如果夏季/冬季时间considderation。 – Naruto