当然,我在使用PHP获取完成日期时遇到了问题,如下所示:
输入:
8/23/2019)Monday, Tuesday, Friday)8)输出:当然,是完成日期(是具有上述输入的9/9/2019 )。
一课就是一天。最终用户的输入字段:

对不起我的英语不好。非常感谢!
发布于 2019-08-25 05:29:32
就像我所看到的,在还剩下课的时候循环,当是星期一、星期二或星期五的时候,再减去。
在循环输出日期之后。
$start = "8/23/2019";
$days = ["Monday", "Tuesday", "Friday"];
$n = 8;
$d = strtotime($start);
while($n>0){
//See if day is in days array
if(in_array(date("l", $d), $days)){
$n--;
}
$d += 86400; // go to next day
}
echo date("m/d/Y", $d-86400); //-86400 because the loop adds one at the end.发布于 2019-08-25 04:49:32
如果我正确理解你的话,就试试这段代码吧)
<?
$startDay = '2019-09-25';
$aSchedule = array(1,2,4);
$iCntShed = count($aSchedule);
$iLessonsCnt = 8;
$iDWStartDay = date('w',strtotime($startDay));
$aDOWMap = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
// first day according Schedule array and startDay
$aWeekDays = array_filter($aSchedule,function($iSDW) use ($iDWStartDay){
return $iSDW>= $iDWStartDay;
});
// day according of week
$nextDate = date('Y-m-d',strtotime($startDay.' next '.$aDOWMap[end($aWeekDays)]));
$i = 0;
while (count($aWeekDays)<$iLessonsCnt) {
$i = $i<$iCntShed ? $i : 0;
$aWeekDays[] = $aSchedule[$i];
$nextDate = date('Y-m-d',strtotime($nextDate.' next '.$aDOWMap[$aSchedule[$i++]]));
}
print_r($aWeekDays);
echo $nextDate;https://stackoverflow.com/questions/57642870
复制相似问题