How can the use of DateTime::diff method help in determining if a person's birthday is in the future or has already passed in PHP?

To determine if a person's birthday is in the future or has already passed in PHP, we can use the DateTime::diff method to calculate the difference between the current date and the person's birthday. If the difference is positive, it means the birthday is in the future. If the difference is negative, it means the birthday has already passed.

$birthday = new DateTime('1990-05-15');
$currentDate = new DateTime();

$interval = $currentDate->diff($birthday);

if($interval->format('%R') === '+'){
    echo "Birthday is in the future";
} else {
    echo "Birthday has already passed";
}