Well I Figured it out,
But I have done soo many things that I don’t know Is this a good approach or not also I want too simplify my process can anybody help me with this ??
Condition Meets
Suppose Today Date is April 12 – 2021
- April 9 – April 10 => Past Events
- April 9 – April 12 => Ongoing Events
- April 12 – April 18 => Ongoing Events
- April 15 – April 18 => Upcoming Events
- April 11 – April 11 => Past Events
- April 8 – April 18 => Ongoing Events
Code
<?php
$event_start_date = get_field('event_date'); //get event start date
$event_end_date = strtotime(get_field('event_end_date')); // convert event date to strtotime
$current_date = date("Y-m-d H:i:s");
$curr_date=strtotime($current_date); //get current date
$the_date=strtotime($event_start_date); //convert event start date to strtotime
$diff=floor(($curr_date-$the_date)/(60*60*24)); //cal for diff between two strtotime - output on float ie float(-1) or float(1)
$date_s = date_create($current_date);
$date_e = date_create(get_field('event_end_date'));
$difference_date = date_diff($date_s,$date_e); //get difference of two dates result is shown on -1 day or 2 day
$diff_days = $difference_date->format("%R%a"); // get the value of two difference date
if($event_end_date < $curr_date ){ // condition to check April-18 < April 12
echo "Past Event";
if($diff == 0){ //condition to check April 12 == April 12
echo "Today Event";
} else if($diff_days == -0){ //condition to check date from April 11 - April 12
echo "Ongoing Event";
}
}elseif($diff > 1 && $diff > -1 || $diff == 0){ //condition to check date from April 12 - April 18 or April 9 - April 14
echo "Ongoing Event";
}else{ // condtion to check the date above the current date
echo "Upcomming Event";
} ?>
If Any one who can Simplify These codes will be great helpful
Thank You