我只想知道如何获得不包括周末的剩余天数。我尝试减去两个日期,但我似乎无法找到任何消除周末的解决方案。这是我的代码:
$date_registered = date('Y-m-d');
$date_planned = $_POST['start_date'];
$dueDate = $date_registered;
$numDays = 3;
$counter = 1;
while ($counter <= $numDays) {
$dueDate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dueDate)) . " +1 day"));
$dayOfTheWeek = date("l",strtotime($dueDate));
if ($dayOfTheWeek == "Saturday" || $dayOfTheWeek == "Sunday") {
continue;
}else {
$counter++;
}
}
echo $date_registered.'<br>';
echo $date_planned.'<br>';
//echo $dueDate;
$remaining_days = strtotime($date_registered) - strtotime($date_planned);
echo $remaining_days/86400;
我不知道如何排除周末。我希望你能帮助我。