How can PHP be used to format dates for MySQL storage?

When storing dates in MySQL, it is important to format them correctly to ensure proper storage and retrieval. PHP provides the `date()` function to format dates according to MySQL's `YYYY-MM-DD` format. By using this function, you can easily convert dates into the appropriate format before inserting them into the database.

$date = "2022-01-15";
$formatted_date = date('Y-m-d', strtotime($date));
echo $formatted_date;