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; $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)); $month = floor($inbetween / $i[0] / $i[0] / $i[1] / $i[3] % $i[4]); $days = floor($inbetween / $i[0] / $i[0] / $i[1] % $i[3]); $hours = floor($inbetween / $i[0] / $i[0] % $i[1]); $minutes = floor($inbetween / $i[0] % $i[0]); $seconds = $inbetween % $i[0]; return $days . " " . $hours . " " . $minutes . " " . $seconds . " " . $inbetween; } echo calcDays(1388389166, 1419925156);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /in/NqfF5:15 Stack trace: #0 /in/NqfF5(24): calcDays(1388389166, 1419925156) #1 {main} thrown in /in/NqfF5 on line 15
Process exited with code 255.
Output for 4.4.5 - 4.4.9, 5.2.0 - 5.6.28
Warning: Division by zero in /in/NqfF5 on line 15 4 23 59 50 31535990
Output for 4.3.0 - 4.4.4, 5.0.0 - 5.1.6
4 23 59 50 31535990