How can PHP developers ensure that date formats in SQL queries align with the format of the date data stored in the database?

When writing SQL queries in PHP that involve date comparisons or manipulations, it is important to ensure that the date format used in the query matches the format of the date data stored in the database. One way to do this is by using the `DATE_FORMAT` function in SQL to convert the date data to a consistent format before comparing or manipulating it.

// Assuming $date is the date input from the user
// Assuming $conn is the database connection object

// Convert the date input to a consistent format using PHP
$formatted_date = date('Y-m-d', strtotime($date));

// Use the DATE_FORMAT function in SQL to ensure the date format aligns
$sql = "SELECT * FROM table WHERE DATE_FORMAT(date_column, '%Y-%m-%d') = '$formatted_date'";

// Execute the SQL query
$result = $conn->query($sql);

// Process the query result
// ...