date.timezoneを設定するとPHPが早くなる

エラーレベルにSTRICTを加えると、次のようなエラーが出ることがあります。

Strict Standards: date(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for '9.0/no DST' instead

また環境によってはWarningレベルで次のようなエラーが出ます。

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead

これは「システムのタイムゾーン設定を使用しているので安全ではない。date.timezone設定かTZ環境変数で設定してください。 」という意味です。

date.timezoneを設定するにはphp.iniに次のように書きます。

[Date]
date.timezone = "Asia/Tokyo"

このとき

date.timezone = 'Asia/Tokyo'

とシングルクオテーションにすると、設定が有効にならないことがあります。

php.iniにdate.timezoneを設定することで、PHPの処理が少し速くなります。

ちなめにエラーレポートにSTRICTを加えるには、php.iniに次のように書きます。

error_reporting = E_ALL | E_STRICT

関連記事

スポンサーリンク

@icon変換 favicon作成ツール

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る