DateTimeZone::__construct timezone_open 新しい DateTimeZone オブジェクトを作成する &reftitle.description; &style.oop; public DateTimeZone::__construct stringtimezone &style.procedural; DateTimeZonefalsetimezone_open stringtimezone 新しい DateTimeZone オブジェクトを作成します。 DateTimeZone オブジェクトは、 3つの異なるタイムゾーンルールへのアクセスを提供します。 ひとつは UTC からのオフセット (type 1), もうひとつはタイムゾーンの省略形 (type 2), そして IANA タイムゾーンデータベースで公開されている タイムゾーン名 (type 3) です。 DateTimeZone オブジェクトは、 DateTimeDateTimeImmutable に設定できます。 こうすることで、 ローカルのタイムゾーンとしてカプセル化された、 タイムゾーンを表示させることができます。 &reftitle.parameters; timezone サポートするタイムゾーン名 のいずれかや、 オフセット値 (+0200)、 またはタイムゾーンの省略名(BST)。 &reftitle.returnvalues; 成功した場合に DateTimeZone を返します。 &return.falseforfailure.style.procedural; &reftitle.errors; 指定されたタイムゾーンが有効なタイムゾーンとして認識できない場合、 DateInvalidTimeZoneException をスローします。PHP 8.3 より前のバージョンでは、 Exception をスローしていました。 &reftitle.changelog; &Version; &Description; 8.3.0 無効な値を指定した場合、 一般的な Exception ではなく、DateInvalidTimeZoneException がスローされるようになりました。 &reftitle.examples; DateTimeZone を作成し、DateTimeImmutable に設定する setTimezone($tzo); echo $local->format(DateTimeInterface::RFC2822 . ' — e') . "\n"; } ]]> &example.outputs; <classname>DateTimeZone</classname> のインスタンスを作成する際のエラー処理 getName() . "\n"; } catch(Exception $e) { echo $e->getMessage() . "\n"; } } ]]> &example.outputs;