
DatePeriod::__construct 메서드에서 'start'과 'end' 인자는 DateTime 객체를 의미합니다.
이 인자들은 반드시 DateTime 객체여야만 합니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$startDate = new DateTime('2022-01-01');
$endDate = new DateTime('2022-12-31');
$datePeriod = new DatePeriod($startDate, new DateInterval('P1D'), $endDate);
위 예제에서 'start' 인자는 2022년 1월 1일, 'end' 인자는 2022년 12월 31일을 의미합니다.
DateInterval 객체를 사용하여 날짜 간격을 지정할 수 있습니다.
DateInterval 객체의 'P1D'는 1일을 의미합니다.
이러한 방식으로 날짜 범위를 생성할 수 있습니다.
2025-06-08 03:27