3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $strtDate = '2015-05-01'; $endDate = '2015-08-31'; $begin = new DateTime($strtDate); $end = new DateTime(date("Y-m-d", strtotime("+1 day", strtotime($endDate)))); // $weekNo = floor($begin->diff($end)->days / 7); $startDateWeekCnt = floor( date('d',strtotime($begin)) / 7) ; // echo $startDateWeekCnt ."\n"; $endDateWeekCnt = floor( date('d',strtotime($end)) / 7) ; //echo $endDateWeekCnt. "\n"; $datediff = strtotime(date('Y-m',strtotime($endDate))."-01") - strtotime(date('Y-m',strtotime($strtDate))."-01"); $totalnoOfWeek = round(floor($datediff/(60*60*24)) / 7) + $endDateWeekCnt - $startDateWeekCnt ; echo $totalnoOfWeek ."\n";
based on UsmmC
Output for 5.2.1 - 7.2.0
Warning: strtotime() expects parameter 1 to be string, object given in /in/phhdV on line 8 Warning: strtotime() expects parameter 1 to be string, object given in /in/phhdV on line 10 13
Output for 5.2.0
13
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/phhdV on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/phhdV on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/phhdV on line 5