What are common pitfalls when using date functions in PHP, and how can they be avoided?

One common pitfall when using date functions in PHP is not considering timezones, which can lead to unexpected results when working with dates and times. To avoid this issue, always set the correct timezone using the `date_default_timezone_set()` function before performing any date-related operations.

// Set the timezone to the desired value
date_default_timezone_set('America/New_York');

// Now you can safely work with dates and times
$currentDate = date('Y-m-d H:i:s');
echo $currentDate;