I am trying to write a program that gives me output according to date comparison. I am using ACF repeater where I have put some event start dates and event end dates.
I have four different event start dates so I want to show results according to the date within the loop. This means if one package has 23 May 2022 and the second package has 10 April 2022 so when I compare then the result will come for the first package registration open and for the second package the result will come registration close.
I have tried following code but it is not working.
function santy_shortcode_race_categories_event_post(){
date_default_timezone_set('Asia/Kolkata');
$result = '<div class="table-responsive">
<table class="table table-bordered" style="text-align:center; background-color:#fff;">
<thead>
<tr class="table-head">
<th>Package</th>
<th>Age Category</th>
<th>Ticket Price</th>
<th>Reg. Link</th>
</tr>
</thead>
<tbody>';
$id = get_the_ID();
$current_date = date("Y-m-d H:i:s");
if (get_field('Race-Categories',$id)) {
while (the_repeater_field('Race-Categories', $id)) {
$event_start_date .= date("Y-m-d H:i:s", strtotime("+5 hours +30 minutes", strtotime(get_sub_field("ticket_registration_start"))));
$event_end_date .= date("Y-m-d H:i:s", strtotime("+5 hours +30 minutes", strtotime(get_sub_field("ticket_registration_end_date"))));
$result .='<tr>';
$result .='<td>'.get_sub_field("package").'</td>';
$result .='<td>'.get_sub_field("age_category").'</td>';
$result .='<td>'.get_sub_field("ticket_price").'</td>';
if ($current_date > $event_start_date) {
$result .= '<td>Registration Open</td>';
} else {
$result .= '<td>Registration Close</td>';
}
$result .='</tr>';
}
} else {
$result .='No Any Race categories allocated for this event. Try other events.';
}
$result .= '</tbody>
</table>
</div>';
return $result;
}