How can one work around the issue of incorrect time calculations in PHP related to daylight saving time changes?

When dealing with time calculations in PHP that may be affected by daylight saving time changes, it's important to use timezone-aware functions and consider the potential discrepancies. One way to work around this issue is to use the DateTime class along with the DateTimeZone class to accurately handle time conversions and adjustments.

$date = new DateTime('2022-03-13 12:00:00', new DateTimeZone('America/New_York'));
$date->setTimezone(new DateTimeZone('UTC'));
echo $date->format('Y-m-d H:i:s');