How can developers ensure that timestamp columns are updated correctly in MySQL when using PHP for database operations?

When updating timestamp columns in MySQL using PHP, developers should use the NOW() function to ensure that the current timestamp is inserted into the database. This function will automatically set the timestamp to the current date and time when the query is executed.

$query = "UPDATE table_name SET timestamp_column = NOW() WHERE id = 1";
$result = mysqli_query($connection, $query);

if($result){
    echo "Timestamp column updated successfully";
} else {
    echo "Error updating timestamp column: " . mysqli_error($connection);
}