What are some potential pitfalls when calculating age from a birthdate stored in a MySQL database using PHP functions?

When calculating age from a birthdate stored in a MySQL database using PHP functions, one potential pitfall is not accounting for timezone differences between the server and the user's location, which can lead to inaccurate age calculations. To solve this issue, it's important to set the timezone appropriately before performing any date calculations.

// Set the timezone to the user's timezone
date_default_timezone_set('America/New_York');

// Fetch the birthdate from the MySQL database
$birthdate = '1990-05-15';

// Calculate the age based on the birthdate
$age = date_diff(date_create($birthdate), date_create('today'))->y;

echo "Age: " . $age;