(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
IntlDateFormatter::getTimeZoneId -- datefmt_get_timezone_id — 取得 IntlDateFormatter 使用的時區 ID
物件導向風格
程序風格
取得 IntlDateFormatter 使用的時區 ID。
formatter
格式器資源。
此格式器使用的時區 ID 字串,失敗時返回 false
。
範例 #1 datefmt_get_timezone_id() 範例
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo '格式器的 timezone_id 為:' . datefmt_get_timezone_id($fmt) . "\n";
datefmt_set_timezone($fmt, 'Europe/Madrid');
echo '現在格式器的 timezone_id 為:' . datefmt_get_timezone_id($fmt);
?>
範例 #2 物件導向範例
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo '格式器的 timezone_id 為:' . $fmt->getTimezoneId() . "\n";
$fmt->setTimezone('Europe/Madrid');
echo '現在格式器的 timezone_id 為:' . $fmt->getTimezoneId();
?>
上述範例將輸出:
timezone_id of the formatter is: America/Los_Angeles Now timezone_id of the formatter is: Europe/Madrid