3v4l.org

run code in 500+ PHP versions simultaneously
<?php function diffInMonth(DateTime $start,DateTime $end): int { list($yearStart,$monthStart,$dayStart) = explode(" ",$start->format("Y m dHis")); list($yearEnd,$monthEnd, $dayEnd) = explode(" ",$end->format("Y m dHis")); $mothDiff = ($yearEnd - $yearStart) * 12 + $monthEnd - $monthStart; if($dayStart > $dayEnd) --$mothDiff; return $mothDiff; } $startDate = new DateTime('2022-11-01 00:00:00.0', new DateTimeZone('Africa/Nairobi')); $endDate = new DateTime('2022-12-01 00:00:00.0', new DateTimeZone('Africa/Nairobi')); $month = diffInMonth($startDate, $endDate); echo $month;
Output for git.master, git.master_jit, rfc.property-hooks
1

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:
53.5 ms | 1245 KiB | 4 Q