Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$startDate = date('Y-m-d', strtotime('-2 years'));
$currentDate = $startDate;
$oddDays = [];
while ($currentDate <= date('Y-m-d')) {
$dayOfMonth = date('j', strtotime($currentDate));
if ($dayOfMonth % 2 !== 0) {
$oddDays[] = $currentDate;
}
$currentDate = date('Y-m-d', strtotime("$currentDate +1 day"));
}
$oddDaysString = implode(',', $oddDays);
echo $oddDaysString;