我想出来了,
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
假设今天的日期是
April 12 - 20214月9日至4月10日;4月9日至4月12日的过往事件;4月12日至4月18日期间正在进行的活动;4月15日至4月18日期间正在进行的活动;4月11日至4月11日即将举行的活动;4月8日至4月18日的过往事件;正在进行的事件
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
非常感谢。