我希望每天插入数据作为选择开始日期和结束日期。 我只使用以下代码计算一周中的一周
$start = new DateTime('2016-11-17');
$end = new DateTime('2017-06-10');
$days = $start->diff($end, true)->days;
$monday = intval($days / 7) + ($start->format('N') + $days % 7 >= 1);
$tuesday = intval($days / 7) + ($start->format('N') + $days % 7 >= 2);
$wednesday = intval($days / 7) + ($start->format('N') + $days % 7 >= 3);
$thursday = intval($days / 7) + ($start->format('N') + $days % 7 >= 4);
$friday = intval($days / 7) + ($start->format('N') + $days % 7 >= 5);
$saturday = intval($days / 7) + ($start->format('N') + $days % 7 >= 6);
$sundays = intval($days / 7) + ($start->format('N') + $days % 7 >= 7);
答案 0 :(得分:0)
$ sundays = intval($ days / 7)+($ start-> format(' N')+ $ days%7< = 7);