3v4l.org

run code in 300+ PHP versions simultaneously
<?php function datediffInWeeks($date1, $date2) { if($date1 > $date2) return datediffInWeeks($date2, $date1); $first = DateTime::createFromFormat('m/d/Y H:i:s', $date1); $second = DateTime::createFromFormat('m/d/Y H:i:s', $date2); return floor($first->diff($second)->days/7); } var_dump(datediffInWeeks('1/2/2013 12:22:38', '6/4/2013'));// 21 var_dump(datediffInWeeks('6/4/2013 13:46:44', '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/6ubbj:7 Stack trace: #0 /in/6ubbj(7): DateTime->diff(false) #1 /in/6ubbj(10): datediffInWeeks('1/2/2013 12:22:...', '6/4/2013') #2 {main} thrown in /in/6ubbj 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/6ubbj:7 Stack trace: #0 /in/6ubbj(7): DateTime->diff(false) #1 /in/6ubbj(10): datediffInWeeks('1/2/2013 12:22:...', '6/4/2013') #2 {main} thrown in /in/6ubbj 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:
52.88 ms | 401 KiB | 8 Q