PHP 日期时间函数 timezone_open()


PHP 日期时间函数 timezone_open()

<?php
   $dateSrc = '2017-06-25 1: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);
?>