3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function datediffInWeeks($date1, $date2) { var_dump(date('W', date2) - date('W', date1)); if($date1 > $date2) return datediffInWeeks($date2, $date1); $first = DateTime::createFromFormat('m/d/Y', $date1); $second = DateTime::createFromFormat('m/d/Y', $date2); return floor($first->diff($second)->days/7) + 1; } var_dump(datediffInWeeks('11/11/2016', '11/13/2016'));
based on LOJa9
Output for 7.3.0alpha1
Warning: Use of undefined constant date2 - assumed 'date2' (this will throw an Error in a future version of PHP) in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be int, string given in /in/dNGPm on line 4 Warning: Use of undefined constant date1 - assumed 'date1' (this will throw an Error in a future version of PHP) in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be int, string given in /in/dNGPm on line 4 int(0) float(1)
Output for 7.2.0 - 7.2.6
Warning: Use of undefined constant date2 - assumed 'date2' (this will throw an Error in a future version of PHP) in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be integer, string given in /in/dNGPm on line 4 Warning: Use of undefined constant date1 - assumed 'date1' (this will throw an Error in a future version of PHP) in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be integer, string given in /in/dNGPm on line 4 int(0) float(1)
Output for 7.0.0 - 7.1.7
Notice: Use of undefined constant date2 - assumed 'date2' in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be integer, string given in /in/dNGPm on line 4 Notice: Use of undefined constant date1 - assumed 'date1' in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be integer, string given in /in/dNGPm on line 4 int(0) float(1)
Output for 5.6.0 - 5.6.28
Notice: Use of undefined constant date2 - assumed 'date2' in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be long, string given in /in/dNGPm on line 4 Notice: Use of undefined constant date1 - assumed 'date1' in /in/dNGPm on line 4 Warning: date() expects parameter 2 to be long, string given in /in/dNGPm on line 4 int(0) float(1)