- floor: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?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));
$month = -20;
$days = floor($inbetween / 60 / 60 / 24 % $i[3]);
$hours = floor($inbetween / 60 / 60 % $i[1]);
$minutes = floor($inbetween / 60 % $i[0]);
$seconds = $inbetween % $i[0];
return $days . " " . $hours . " " . $minutes . " " . $seconds . " " . $inbetween;
}
echo calcDays(1388389166, 1419925156);