Given the $interval is a DateInterval object following conditional statement is true whether the anniversary is within 1 year prior to the current date = 0 or the anniversary is within 1 year post the current date = -0.
$interval = $anniversary->diff($current_Date);
if ($interval->format('%r%y') < 0){
do something
}
- I can't use abs because they are both 0
- I can't use <= 0 because they both are
- I can't use >= 0 because this sets to true on other cases which I don't want
- I can't use < 0 because 0 isn't and I want 0 to be true
- I can't use == 0 because both are true
- I can't use > 0 because 0 isn't and I want 0 to be true
So I want to be able to say something like is this number signed negative but no such thing exists as far as I can tell. Any thoughts?
** Edit **
The solution is to compare the date objects and decide if they are in the appropriate DateInterval:
if ($anniversary < $current_Date && $interval->format('%r%y') == 0){