3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('Europe/Berlin'); # timezone with DST function daysBetweenDates($startDate, $endDate) { list($year1, $month1, $day1) = explode('-', $startDate); list($year2, $month2, $day2) = explode('-', $endDate); $f = mktime(0, 0, 0, $month2, $day2, $year2); $i = mktime(0, 0, 0, $month1, $day1, $year1); $difference = $f - $i; $days = floor($difference/86400); return $days; } $startDate = '2014-10-14'; $endDate = '2014-10-28'; print_r(daysBetweenDates($startDate, $endDate));
Output for 5.1.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
14
Output for 5.0.0 - 5.0.5
<br /> <b>Fatal error</b>: Call to undefined function date_default_timezone_set() in <b>/in/eOoYN</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: date_default_timezone_set() in <b>/in/eOoYN</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: date_default_timezone_set() in <b>/in/eOoYN</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: date_default_timezone_set() in <b>/in/eOoYN</b> on line <b>2</b><br />