PHP中的date_default_timezone_get()函数
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
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志