What potential pitfalls should be avoided when calculating dates in PHP?
When calculating dates in PHP, one potential pitfall to avoid is not accounting for timezones. It is important to always set the timezone using `date_default_timezone_set()` to ensure consistent results across different environments. Additionally, be cautious when using functions like `strtotime()` as they can behave unexpectedly with certain date formats.
// Set the timezone to avoid inconsistencies
date_default_timezone_set('UTC');
// Calculate a future date
$future_date = date('Y-m-d H:i:s', strtotime('+1 week'));
echo $future_date;