What are the potential pitfalls of using timestamps to calculate age in PHP?

Using timestamps to calculate age in PHP can lead to inaccuracies due to differences in time zones, leap years, and daylight saving time adjustments. To mitigate this, it is recommended to use the DateTime class in PHP, which provides more accurate date calculations.

$birthdate = '1990-05-15';
$today = new DateTime();
$diff = $today->diff(new DateTime($birthdate));
echo $diff->y;