What are the common pitfalls to avoid when querying and outputting dates in PHP?

One common pitfall when querying and outputting dates in PHP is not handling timezones properly, which can lead to incorrect date and time displays. To avoid this issue, always set the default timezone using `date_default_timezone_set()` to ensure consistency in date and time calculations.

// Set the default timezone to avoid date and time display issues
date_default_timezone_set('UTC');

// Query and output the current date and time
$currentDate = date('Y-m-d H:i:s');
echo $currentDate;