Set the time zone for the DateTime object in PHP
Description
The following code shows how to set the time zone for the DateTime object.
Example
/*from ww w . j a v a 2 s. c om*/
<?php
$date = new DateTime('2014-01-01', new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";
$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->format('Y-m-d H:i:sP') . "\n";
?>
The code above generates the following result.