How can proper targeting be achieved when using NOW() to compare dates in a database query?

When using NOW() to compare dates in a database query, it is important to ensure that the date format is consistent between the database and the PHP code. One way to achieve proper targeting is by using the DATE() function in MySQL to extract only the date part of the NOW() function. This will allow for accurate date comparisons in the query.

// Assuming connection to database is already established

// Get the current date in YYYY-MM-DD format
$currentDate = date('Y-m-d');

// Query to select records where the date is equal to the current date
$query = "SELECT * FROM table_name WHERE DATE(date_column) = '$currentDate'";

$result = mysqli_query($conn, $query);

// Process the result set
// ...