What is the recommended data type to store birthdates in a database for easy filtering and calculations in PHP?

When storing birthdates in a database for easy filtering and calculations in PHP, it is recommended to use the DATE data type. This allows for efficient date-based queries and calculations, such as finding all users born after a certain date or calculating their age based on their birthdate.

// Creating a table with a DATE column for storing birthdates
$sql = "CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50),
    birthdate DATE
)";

// Inserting a user with a birthdate into the table
$sql = "INSERT INTO users (name, birthdate) VALUES ('John Doe', '1990-05-15')";

// Querying users born after a certain date
$birthdateFilter = '1990-01-01';
$sql = "SELECT * FROM users WHERE birthdate > '$birthdateFilter'";