Good evening!
Problem: The problem is to compare 2 dates in PHP. I want to only compare day and month, excluding the year. I want the code to first check the month, if the month is same or less than current month. If it's true, move on to check the day. If the day is equal to, or less than current day, execute a custom code.
What I've tried: Here is where I got so far -
<?php
$oldDate = "26/02/1815";
$latestDate = explode("/", $oldDate);
$year = $latestDate[2];
$month = $latestDate[1];
$day = $latestDate[0];
$newDate = $month.'/'.$day.'/'.$year;
$nowDate = date('m/d/Y');
$nownowDate = explode("/", $nowDate);
$nowYear = $nownowDate[2];
$nowMonth = $nownowDate[0];
$nowDay = $nownowDate[1];
if ($nowMonth <= $month) {
if ($nowDay <= $day) {
echo<<<NEXTDATE
<li class="next"><?php echo link_to_next_item_show(); ?></li> //This is the custom code
NEXTDATE;
}
}
?>
I feel that there is something wrong with my IFs statement.