In what scenarios is it advisable to store birth dates instead of ages in a database when working with PHP?

It is advisable to store birth dates instead of ages in a database when working with PHP if you need to calculate precise ages at any given time. Storing birth dates allows for accurate age calculations that take into account leap years and varying month lengths. Additionally, storing birth dates provides flexibility for future date-based calculations or queries.

// Storing birth dates in a database table
$birthdate = '1990-05-15';

// Calculate age based on birth date
$birthdate = new DateTime($birthdate);
$today = new DateTime();
$age = $today->diff($birthdate)->y;

echo "Age: " . $age;