What is the recommended format for input date values when checking for the occurrence of a specific day within a date range in PHP?

When checking for the occurrence of a specific day within a date range in PHP, it is recommended to use the 'Y-m-d' format for input date values. This format ensures consistency and accuracy when comparing dates within a range. By converting the input dates to this format, you can easily check if a specific day falls within the given date range.

// Example code to check for the occurrence of a specific day within a date range
$startDate = date('Y-m-d', strtotime('2022-01-01'));
$endDate = date('Y-m-d', strtotime('2022-12-31'));
$specificDay = 'Monday';

$currentDate = $startDate;
while ($currentDate <= $endDate) {
    if (date('l', strtotime($currentDate)) == $specificDay) {
        echo $specificDay . ' occurs on ' . $currentDate . PHP_EOL;
    }
    $currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day'));
}