note 77217 deleted from function.timezone-open by nlopess
| From: | nlopess@php.net | Date: | Sat, 01 Sep 2007 12:02:24 +0000 |
| Subject: | note 77217 deleted from function.timezone-open by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130007@lists.php.net to get a copy of this message | ||
Note Submitter: mcmohd at gmail dot com
----
Following is the example on using both the above functions:
<?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 = new DateTimeZone( 'America/Chicago' );
$dateTime->setTimezone( $DateTimeZone );
$NewDateTimeZone = $dateTime->getTimezone ();
echo 'New timeZone is '. timezone_name_get ($NewDateTimeZone);
?>
This will produce following result: ( May be different on your computer )
New timeZone is America/Chicago
New timeZone is America/Chicago
Thanks
http://www.tutorialspoint.com/php