3v4l.org

run code in 300+ PHP versions simultaneously
<?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); $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempMonth = date('n', strtotime('-1 year', $second)); for($n = 0; $n < 12; $n++) { var_dump($temp); $tempMonth -= 1; if($temp >= $i[5][$tempMonth]) { $temp -= $i[5][$n]; } else { $days = $temp; var_dump($days); break; } } $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 $month . " " . $days . " " . $hours . " " . $minutes . " " . $seconds . " " . $inbetween; } echo calcDays(1388389157, 1419925156);
Output for git.master, git.master_jit, rfc.property-hooks
float(364) float(333) float(304) float(273) float(243) float(212) float(182) float(151) float(120) float(90) float(59) float(29) float(29) Deprecated: Implicit conversion from float 12.166666280864197 to int loses precision in /in/45nd7 on line 32 Deprecated: Implicit conversion from float 8759.999722222221 to int loses precision in /in/45nd7 on line 34 Deprecated: Implicit conversion from float 525599.9833333333 to int loses precision in /in/45nd7 on line 35 12 29 23 59 59 31535999

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
68.67 ms | 402 KiB | 8 Q