I am checking exception-dates against today’s date. If TRUE some code needs te be triggered…. but it always returns FALSE.
I’m certain that the output of both is in the exact same way (f.i. 2022-01-28). I even echoed both with good results.
I also believe both strings are real dates so why does the IF statement always returns FALSE??
function yl_opening_status_icon_shortcode() {
if (have_rows('booking_settings_exceptions', 'booking_settings')) {
while (have_rows('booking_settings_exceptions', 'booking_settings')) { the_row();
$today_date = date('Y-m-d');
$exceptions = get_sub_field('booking_settings_exceptions_date');
$exception = str_replace('/', '-', $exceptions);
$whole_day = get_sub_field('booking_settings_exceptions_whole_day');
$reason = get_sub_field('booking_settings_exceptions_reason');
$exception_dates = array(date("Y-m-d", strtotime($exception)));
if (in_array($today_date, $exception_dates)) {
// This always returns false, even if it's true
// echo $today_date and echo $exception_dates work and output does have same values
// and I believe there both set as real dates so why doesn't it pass here..?
}
}
}
return $output;
}
I was missing this line:
$exception_date = getDate($exception_dates);
As it turned out, the exceptions weren’t real dates after all.