Date/Time 函数
在线手册:中文 英文
PHP手册

date_timezone_set

(PHP 5 >= 5.2.0)

date_timezone_set别名 DateTime::setTimezone()

说明

此函数是该函数的别名: DateTime::setTimezone()


Date/Time 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: 别名 DateTime::setTimezone

用户评论:

fl4sh dot b0y at live dot fr (07-Aug-2009 10:11)

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