What is the best practice for inserting a date into a TIMESTAMP field in a MySQL database using PHP?

When inserting a date into a TIMESTAMP field in a MySQL database using PHP, it is best practice to use the current date and time in the correct format. This can be achieved by using the PHP function `date()` to format the current date and time according to the MySQL TIMESTAMP format 'Y-m-d H:i:s'. By doing so, you ensure that the date is inserted correctly into the TIMESTAMP field.

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

// Get current date and time in MySQL TIMESTAMP format
$current_date = date('Y-m-d H:i:s');

// Insert current date into TIMESTAMP field
$query = "INSERT INTO table_name (timestamp_field) VALUES ('$current_date')";
$mysqli->query($query);

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