3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function calcDays($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $minute = 60; $hour = $minute * 60; $day = $hour * 24; $week = $day * 7; $month = 30; $days = floor($inbetween / 60 / 60 / 24 - 30); $hours = floor($inbetween / 60 / 60 / 60); $minutes = floor($inbetween / 60); $seconds = $inbetween % $minutes; return $days . " " . $hours . " " . $minutes . " " . $seconds . " " . $inbetween; } echo calcDays(1388389156, 1391067562);
Output for 4.3.0 - 7.1.0
1 12 44640 6 2678406