What is the significance of using the NOW() function in a MySQL query when inserting date and time values?

When inserting date and time values into a MySQL database, using the NOW() function can automatically insert the current date and time at the time of the query execution. This ensures that the correct timestamp is recorded without needing to manually input it in the query.

// Connect to MySQL database
$mysqli = new mysqli("localhost", "username", "password", "database");

// Insert current date and time using NOW() function
$query = "INSERT INTO table_name (date_time_column) VALUES (NOW())";
$mysqli->query($query);

// Close database connection
$mysqli->close();