What are best practices for storing dates in a MySQL database to avoid issues with date calculations in PHP?

When storing dates in a MySQL database to avoid issues with date calculations in PHP, it is best to use the DATETIME data type in MySQL. This data type stores both the date and time information, allowing for accurate calculations in PHP. Additionally, it is important to ensure that the time zone settings are consistent between MySQL and PHP to prevent any discrepancies in date and time calculations.

// Example of storing a date in MySQL using DATETIME data type
$date = date('Y-m-d H:i:s'); // Get current date and time in PHP format
$query = "INSERT INTO table_name (date_column) VALUES ('$date')";
// Execute the query to insert the date into the MySQL database