3v4l.org

run code in 300+ PHP versions simultaneously
<?php function datediffInWeeks($date1, $date2) { if($date1 > $date2) return datediffInWeeks($date2, $date1); $first = DateTime::createFromFormat('Y-m-d', $date1); $second = DateTime::createFromFormat('Y-m-d', $date2); return floor($first->diff($second)->days/7); } var_dump(datediffInWeeks('2015-2-1', '6/21/2016'));// 21 var_dump(datediffInWeeks('2013-6-1', '1/2/2013'));// 21
Output for git.master, git.master_jit
Fatal error: Uncaught TypeError: DateTime::diff(): Argument #1 ($targetObject) must be of type DateTimeInterface, bool given in /in/tnWQk:7 Stack trace: #0 /in/tnWQk(7): DateTime->diff(false) #1 /in/tnWQk(10): datediffInWeeks('2015-2-1', '6/21/2016') #2 {main} thrown in /in/tnWQk on line 7
Process exited with code 255.
Output for rfc.property-hooks
Fatal error: Uncaught TypeError: DateTime::diff(): Argument #1 ($targetObject) must be of type DateTimeInterface, false given in /in/tnWQk:7 Stack trace: #0 /in/tnWQk(7): DateTime->diff(false) #1 /in/tnWQk(10): datediffInWeeks('2015-2-1', '6/21/2016') #2 {main} thrown in /in/tnWQk on line 7
Process exited with code 255.

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