How can the NOW() function in MySQL be utilized to store the current date and time in a DATETIME column when working with PHP?

When working with PHP and MySQL, you can utilize the NOW() function in MySQL to store the current date and time in a DATETIME column. This can be achieved by simply including the NOW() function in the SQL query when inserting or updating records in the database.

<?php
// Connect to MySQL database
$connection = mysqli_connect("localhost", "username", "password", "database");

// Insert current date and time into a DATETIME column using NOW() function
$query = "INSERT INTO table_name (datetime_column) VALUES (NOW())";
mysqli_query($connection, $query);

// Close database connection
mysqli_close($connection);
?>