<?php
date_default_timezone_set('UTC');
$utc = new DateTimeZone('UTC');
$time = DateTime::createFromFormat('Y-m-d H:i:s', '2014-05-19 11:30:00', $utc);
foreach (array('UTC', 'Europe/London', 'BST', 'Etc/GMT+1', 'GMT+1', 'CEST', 'EST', 'GMT-5') as $abbr) {
$local = clone $time;
try {
$zone = new DateTimeZone($abbr);
$local2 = new DateTime('2014-05-19 11:30:00', $zone);
$local->setTimezone(new DateTimeZone($abbr));
echo "{$abbr}: {$zone->getOffset($time)} {$local->format('H:i P')}", PHP_EOL;
echo "{$abbr}: {$zone->getOffset($time)} {$local2->format('H:i P')}", PHP_EOL;
} catch (Exception $e) {
echo "{$abbr}: ERROR - {$e->getMessage()}", PHP_EOL;
}
}
preferences:
43.21 ms | 402 KiB | 5 Q