Are there any best practices for handling timezone conversions and adjustments in PHP scripts to ensure accurate display of event times?

When working with event times in PHP scripts, it's important to handle timezone conversions and adjustments to ensure accurate display across different timezones. One way to achieve this is by setting the default timezone for your script and converting event times to this timezone before displaying them.

// Set the default timezone for the script
date_default_timezone_set('UTC');

// Assuming $eventTime is the timestamp of the event in UTC timezone
$eventTime = '2022-01-01 12:00:00';

// Convert event time to a specific timezone (e.g. 'America/New_York')
$timezone = new DateTimeZone('America/New_York');
$dateTime = new DateTime($eventTime);
$dateTime->setTimezone($timezone);

// Display the event time in the desired timezone
echo $dateTime->format('Y-m-d H:i:s');