Converting UTC to local time

I’m importing dates that are in UTC format. Is there an easy way to convert this to EST? Daylight savings is the hitch. It doesn’t switch the same date every year, so it seems like figuring the offset based on the date would be tricky.

Does anyone have any ideas or suggestions?

E

PHP’s DateTime (documentation) class makes working with timezones easy.


$date = new DateTime('2011-11-10 20:17:23', new DateTimeZone('UTC'));
$date->setTimezone(new DateTimeZone('EST'));

echo $date->format('Y-m-d H:i:s O'); // 2011-11-10 15:17:23 -0500

Salathe,

Thank you! Brilliant.

-E