3v4l.org

run code in 300+ PHP versions simultaneously
<?php function percentYear($a, $b) { //A rather complex function that calculates the difference between two dates in terms of the year that they're in. //Returns a number that corresponds to the amount of years between the two provided dates. //Takes in two dates and returns the decimal of days per year for that specific year // I made this in order to fix the issue of leap years. if(strtotime($a)<strtotime($b)){ list($a, $b) = array($b, $a); } $aYearDay = date("z", strtotime($a)) + 1; $aYearDays = date("z", strtotime(date("Y", strtotime($a))."-12-31")) + 1; $aPercent = $aYearDay/$aYearDays; $bYearDay = date("z", strtotime($b)) + 1; $bYearDays = date("z", strtotime(date("Y", strtotime($b))."-12-31")) + 1; $bPercent = $bYearDay/$bYearDays; if(date("Y", strtotime($a))!=date("Y", strtotime($b))) { $aPercent += abs(date("Y", strtotime($a))-date("Y", strtotime($b))); } return abs($aPercent-$bPercent); } echo percentYear('2013-12-14', '2014-2-14');
Output for git.master, git.master_jit, rfc.property-hooks
0.16986301369863

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:
45.23 ms | 401 KiB | 8 Q