date_default_timezone_get()函数返回默认时区。
date_default_timezone_get(void)
无效-NA
date_default_timezone_get()函数返回一个字符串。
以下是一个例子-
<?php
echo "Old time zone is ". date_default_timezone_get();
$timeZone = 'America/Costa_Rica';
if( date_default_timezone_set( $timeZone) ){
# Now get this time zone.
echo "New time zone is ". date_default_timezone_get();
}
?>输出结果
以下是输出-
Old time zone is UTC New time zone is America/Costa_Rica
让我们看另一个例子-
<?php echo date_default_timezone_get(); ?>
输出结果
以下是输出-
UTC