<?php
foreach (['Etc/GMT+12', 'Etc/GMT-10'] as $timezone) {
$dTZ = new DateTimeZone($timezone);
// Create a DateTime using the DateTimeZone object
// This will display both formatted and unix timestamp as expected
$dT = new DateTime('2013-12-13 18:49:00', $dTZ);
echo $dT->format('Y-m-d H:i:s T'), PHP_EOL;
echo $dT->getTimestamp(), PHP_EOL;
// Create a DateTime using only a string representation
// This will display the formatted date/time as expected,
// but with the incorrect timezone
// The value returned by getTimestamp() for format('U') will
// be off by 2*offset
$dT2 = new DateTime($dT->format('Y-m-d H:i:s T'));
echo $dT2->format('Y-m-d H:i:s T'), PHP_EOL;
echo $dT2->getTimestamp(), PHP_EOL, PHP_EOL;
}
Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/GMT+12) in /in/RCA06:4
Stack trace:
#0 /in/RCA06(4): DateTimeZone->__construct('Etc/GMT+12')
#1 {main}
thrown in /in/RCA06 on line 4
Process exited with code 255.