CakeFest 2024: The Official CakePHP Conference

IntlDateFormatter::getTimeZoneId

datefmt_get_timezone_id

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

IntlDateFormatter::getTimeZoneId -- datefmt_get_timezone_idIntlDateFormatter が使用するタイムゾーン ID を取得する

説明

オブジェクト指向型

public IntlDateFormatter::getTimeZoneId(): string|false

手続き型

datefmt_get_timezone_id(IntlDateFormatter $formatter): string|false

IntlDateFormatter が使用するタイムゾーン ID を取得します。

パラメータ

formatter

Formatter リソース。

戻り値

この 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 of the formatter is: ' . datefmt_get_timezone_id($fmt) . "\n";
datefmt_set_timezone($fmt, 'Europe/Madrid');
echo
'Now timezone_id of the formatter is: ' . datefmt_get_timezone_id($fmt);

?>

例2 オブジェクト指向の例

<?php
$fmt
= new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo
'timezone_id of the formatter is: ' . $fmt->getTimezoneId() . "\n";
$fmt->setTimezone('Europe/Madrid');
echo
'Now timezone_id of the formatter is: ' . $fmt->getTimezoneId();

?>

上の例の出力は以下となります。

timezone_id of the formatter is: America/Los_Angeles
Now timezone_id of the formatter is: Europe/Madrid

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top