Copy
$start = date("Y-m-01"); // 2017-12-01 (string)
$end = date("Y-m-d"); // 2017-12-20 (string)
while ($start <= $end) { // 2017-12-01 ~ 2017-12-20 까지 돌림
echo $start;
$start = date("Y-m-d", strtotime($start . "+1 day"));
}
위에것으로 하면 잘 돌아가긴 하는데 궁금한것은 문자열이지않나요??
문자열인데 반복문에 돌아가는게 신기하네요. 제생각으로는 .
Copy
while (strtotime($start) <= strtotime($end)) { 이런식으로 해야하는게 맞지안한요?
}
|
답변 2개
답변을 작성하려면 로그인이 필요합니다.