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); $months = 0; $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; while(TRUE) { var_dump($temp); if($temp >= $i[5][$tempMonth]) { $months += 1; $temp -= $i[5][$tempMonth]; } else { $days = $temp; break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $years = date('Y', $second) - date('Y', $first) + $months / 12; $months = $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(1388389157, 1704094758);
Output for git.master, git.master_jit, rfc.property-hooks
float(3654) float(3623) float(3594) float(3563) float(3533) float(3502) float(3472) float(3441) float(3410) float(3380) float(3349) float(3319) float(3288) float(3259) float(3228) float(3198) float(3167) float(3137) float(3106) float(3075) float(3045) float(3014) float(2984) float(2953) float(2924) float(2893) float(2863) float(2832) float(2802) float(2771) float(2740) float(2710) float(2679) float(2649) float(2618) float(2589) float(2558) float(2528) float(2497) float(2467) float(2436) float(2405) float(2375) float(2344) float(2314) float(2283) float(2254) float(2223) float(2193) float(2162) float(2132) float(2101) float(2070) float(2040) float(2009) float(1979) float(1948) float(1919) float(1888) float(1858) float(1827) float(1797) float(1766) float(1735) float(1705) float(1674) float(1644) float(1613) float(1584) float(1553) float(1523) float(1492) float(1462) float(1431) float(1400) float(1370) float(1339) float(1309) float(1278) float(1249) float(1218) float(1188) float(1157) float(1127) float(1096) float(1065) float(1035) float(1004) float(974) float(943) float(914) float(883) float(853) float(822) float(792) float(761) float(730) float(700) float(669) float(639) float(608) float(579) float(548) float(518) float(487) float(457) float(426) float(395) float(365) float(334) float(304) float(273) float(244) float(213) float(183) float(152) float(122) float(91) float(60) float(30) Deprecated: Implicit conversion from float 87696.00027777777 to int loses precision in /in/r6NPK on line 38 Deprecated: Implicit conversion from float 5261760.016666667 to int loses precision in /in/r6NPK on line 39 20.916666666667 years 11 months 30 days 0 hours 0 minutes 1 seconds

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:
41.27 ms | 405 KiB | 8 Q