PHP date_timezone_set()関数
例
DateTimeオブジェクトのタイムゾーンを設定します。
<?php
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>
定義と使用法
date_timezone_set()関数は、DateTimeオブジェクトのタイムゾーンを設定します。
構文
date_timezone_set(object, timezone)
パラメータ値
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create(). This function modifies this object |
timezone | Required. Specifies a DateTimeZone object that represents the desired time zone. Tip: Look at a list of all supported timezones in PHP |
技術的な詳細
戻り値: | メソッドチェーンのDateTimeオブジェクトを返します。失敗するとFALSE |
---|---|
PHPバージョン: | 5.2+ |
変更ログ: | PHP 5.3:戻り値をNULLからDateTimeに変更しました(成功時) |
❮PHPの日付/時刻リファレンス