Can somebody please help me?
I want to add dates from DatePeriod() to my array.
I have the following code, which works, but it adds only the last row passed from SQL (the SQL query returns more than one start and end date):
while($rowLD = $getDataLD->fetch_assoc()) {
$strDateFrom = $rowLD['ld_time_start'];
$strDateTo = $rowLD['ld_time_end'];
$periodLD = new DatePeriod(new DateTime($strDateFrom), new DateInterval('P1D'), new DateTime($strDateTo.' +1 day'));
}
foreach ($periodLD as $dateLD) {
$datesLD[] = $dateLD->format("Y-m-d");
}
Thank you.