此函数是该函数的别名: DateTime::setTimezone()
fl4sh dot b0y at live dot fr (2009-08-07 02:11:22)
Return Value
Returns NULL on success or FALSE on failure.
Example
Following is the usage of this function:
<?php
$dateSrc = '2007-04-19 12:50 GMT';
$dateTime = date_create( $dateSrc);
$DateTimeZone = timezone_open ( 'America/Chicago' );
date_timezone_set( $dateTime, $DateTimeZone );
$NewDateTimeZone = date_timezone_get($dateTime);
echo 'New timeZone is '. timezone_name_get($NewDateTimeZone);
echo "\n";
# Using second function.
$dateTime = new DateTime($dateSrc);
$DateTimeZone = timezone_open ( 'America/Chicago' );
$dateTime->setTimezone( $DateTimeZone );
$NewDateTimeZone = $dateTime->getTimezone ();
echo 'New timeZone is '. timezone_name_get ($NewDateTimeZone);
?>
This will produce following result:
New timeZone is America/Chicago
New timeZone is America/Chicago