0
이 함수는 시작, 끝 및 반복 날짜를 검사합니다. 따라서 시작 날짜와 종료 날짜는 날짜 범위로 사용되며 repeatFollowup은 해당 기간 동안 매월 반복되는 날짜입니다. 지연을 일으키는 원인이되는 코드를 디버그 할 수 없거나 무한 루프입니까?실행 시간 초과 PHP Carbon
도움을 주시면 감사하겠습니다. 당신은
public function calculateDaysOfMonth($startDate, $endDate, $repeatFollowup){
$begin = new \DateTime($startDate);
$end = new \DateTime($endDate);
$repeatDate = new \DateTime($begin->format('Y-m').'-'.date($repeatFollowup));
$days = array();
elseif ($repeatFollowup==30){
$newDate = Carbon::parse('first day of'.$repeatDate->format('Y-m-d'));
//var_dump($newDate->format('Y'));die();
while($repeatDate<=$end){
if($repeatDate->format('m')==2){
$days[] = $newDate->addDays(27);
$newDate->modify('first day of next month')
}
else{
$days[] = $newDate->addDays(29);
$newDate->modify('first day of next month')
}
}
var_dump($days);die();
return $days;
}
}
'$ repeatDate'또는 '$ end'을 루프 내부에서 변경하지 않으므로 자연스럽게 끝나지 않습니다. –
도움을 주셔서 감사합니다! 나는 별다른 문제가 없다는 것을 알 수있다. 그것은 실제로 지정된 날짜를 추가하는 것이 아니라 매월 첫날을 출력하는 것이다. –