What potential issues might arise when calculating age in PHP based on a birthdate?

One potential issue when calculating age in PHP based on a birthdate is not accounting for leap years. This can result in inaccurate age calculations, especially for individuals born on February 29th during a leap year. To solve this issue, you can use the DateTime class in PHP, which automatically handles leap years when calculating differences between dates.

$birthdate = '1992-02-29';
$today = new DateTime();
$birthday = new DateTime($birthdate);
$age = $today->diff($birthday)->y;

echo "Age: " . $age;