3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php 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 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
14