What is the correct format for storing date and time in a MySQL database using PHP?

When storing date and time in a MySQL database using PHP, the recommended format is the MySQL DATETIME format 'Y-m-d H:i:s'. This format ensures that the date and time values are stored accurately and can be easily retrieved and manipulated in queries.

// Assuming $date_time contains the date and time value to be stored
$date_time = date('Y-m-d H:i:s');

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

// Insert date and time value into database
$query = "INSERT INTO table_name (date_time_column) VALUES ('$date_time')";
$mysqli->query($query);

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