我想计算不包括存储在我的数据库中的假期的天数。 但是我收到了错误:
致命错误:调用未定义的函数isWithinDates()
$holidays = array();
$get_holidays = mysqli_query($link,"SELECT * FROM holiday_list");
while ($fetch_holidays = mysqli_fetch_array($get_holidays)){
$holidays[]=$fetch_holidays['holiday_date'];
}
echo $begin_date = $emp_leave_data['startDate'];
echo $end_date = $last_date;
$exclude = 0;
// Loop over holidays to find out whether they are in the range
foreach ($holidays as $holiday) {
if (isWithinDates(new DateTime($holiday), $begin_date, $end_date)) {
$exclude++;
}
}
function isWithinDates(DateTime $date, DateTime $start, DateTime $end)
{
return $date >= $start && $date <= $end;
}
// Get the amount of days between our start date and the end date
// and subtract the amount of days that we know to be holidays
echo $duration = $begin_date->diff($end_date)->days - $exclude + 1;