PHP timezone_open() 函數

實例

創建新的 DateTimeZone 對象,然后返回時區的名稱:

<?php
$tz=timezone_open("Asia/Shanghai");
echo timezone_name_get($tz);
?>

運行實例

定義和用法

timezone_open() 創建新的 DateTimeZone 對象。

語法

timezone_open(timezone);
參數 描述
timezone

必需。規定時區。

提示:查看 PHP 中支持的所有時區列表

技術細節

返回值: 若成功則返回 DateTimeZone 對象,失敗則返回 FALSE。
PHP 版本: 5.2+