What are some best practices for handling time zone conversions in PHP to avoid errors?

Handling time zone conversions in PHP can be tricky due to the potential for errors when converting between different time zones. To avoid these errors, it's best to set the default time zone for your PHP script using `date_default_timezone_set()` and then explicitly specify the time zone when creating or manipulating DateTime objects.

// Set the default time zone for the script
date_default_timezone_set('America/New_York');

// Create a DateTime object with the current time
$now = new DateTime('now');

// Specify a different time zone when creating a DateTime object
$date = new DateTime('2022-01-01 12:00:00', new DateTimeZone('Asia/Tokyo'));

// Convert a DateTime object to a different time zone
$date->setTimezone(new DateTimeZone('Europe/London'));