What are common pitfalls when using strtotime in PHP to calculate dates?

Common pitfalls when using strtotime in PHP to calculate dates include not specifying a valid date format, not accounting for timezone differences, and not handling edge cases like leap years or daylight saving time changes. To avoid these issues, always provide strtotime with a well-formatted date string and consider using date_default_timezone_set to set the timezone explicitly.

// Example of using strtotime with proper date format and timezone handling
$dateString = '2022-12-31';
$timestamp = strtotime($dateString);
// Set timezone to UTC
date_default_timezone_set('UTC');
echo date('Y-m-d', $timestamp);