downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DateTimeZone::getLocation> <DateTimeZone
Last updated: Fri, 13 Nov 2009

view this page in

DateTimeZone::__construct

(PHP 5 >= 5.2.0)

DateTimeZone::__construct新しい DateTimeZone オブジェクトを作成する

説明

DateTimeZone::__construct ( string $timezone )

新しい DateTimeZone オブジェクトを作成します。

パラメータ

timezone

いずれかの タイムゾーン

返り値

成功した場合に DateTimeZone を返します。

エラー / 例外

このメソッドは、指定したタイムゾーンが無効な形式だった場合に Exception をスローします。

例1 DateTimeZone のインスタンスを作成する際のエラー処理

<?php
// エラー処理は、例外をキャッチすることで行います
$timezones = array('Europe/London''Mars/Phobos''Jupiter/Europa');

foreach (
$timezones as $tz) {
    try {
        
$mars = new DateTimeZone($tz);
    } catch(
Exception $e) {
        echo 
$e->getMessage() . '<br />';
    }
}
?>

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

DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (Mars/Phobos)
DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (Jupiter/Europa)



add a note add a note User Contributed Notes
DateTimeZone::__construct
There are no user contributed notes for this page.

DateTimeZone::getLocation> <DateTimeZone
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites