@ 2013-12-30T10:39:39Z <?php
function calcDays($startdate, $enddate) {
$first = $startdate < $enddate ? $startdate : $enddate;
$second = $startdate < $enddate ? $enddate : $startdate;
$inbetween = $second - $first;
$i[0] = 60;
$i[1] = 24;
$i[2] = 7;
$i[3] = date('t', strtotime('-1 month', $second));
$i[4] = date('L', strtotime('-1 year', $second)) ? 366 : 365;
$i[5] = array(31, (date('L', strtotime('-1 year', $second)) ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$months = 0;
$days = 0;
$temp = floor($inbetween / $i[0] / $i[0] / $i[1]);
$tempDays = floor($temp % 365);
$tempMonth = date('n', strtotime('-1 year', $second)) - 1;
for($n = 0; $n < 12; $n++) {
var_dump($tempDays);
if($tempDays >= $i[5][$tempMonth]) {
$months += 1;
$tempDays -= $i[5][$tempMonth];
} else {
$days = $tempDays;
break;
}
$tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0;
}
$years = floor(date('Y', $second) - date('Y', $first) + $months / 12);
$months = floor($months % 12);
$hours = floor($inbetween / $i[0] / $i[0] % $i[1]);
$minutes = floor($inbetween / $i[0] % $i[0]);
$seconds = $inbetween % $i[0];
return $years . " years " . $months . " months " . $days . " days " . $hours . " hours " . $minutes . " minutes " . $seconds . " seconds";
}
echo calcDays(1388789157, 1704094758);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 float(364)
float(333)
float(304)
float(273)
float(243)
float(212)
float(182)
float(151)
float(120)
float(90)
float(59)
float(29)
Deprecated: Implicit conversion from float 87584.88916666666 to int loses precision in /in/Z8g5d on line 39
Deprecated: Implicit conversion from float 5255093.35 to int loses precision in /in/Z8g5d on line 40
10 years 11 months 29 days 8 hours 53 minutes 21 seconds Output for 4.3.0 - 4.3.11 , 4.4.0 - 4.4.9 , 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.20 , 7.2.0 - 7.2.33 , 7.3.12 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 float(364)
float(333)
float(304)
float(273)
float(243)
float(212)
float(182)
float(151)
float(120)
float(90)
float(59)
float(29)
10 years 11 months 29 days 8 hours 53 minutes 21 seconds preferences:dark mode live preview
279.02 ms | 405 KiB | 356 Q