エラー対応:Fatal error: Uncaught exception ‘Exception’ with message ‘DateTime::__construct(): …

Pocket
2 interests

Fatal error: Uncaught exception ‘Exception’ with message ‘DateTime::__construct(): 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’ in /path/to/FileName.php:123 Stack trace: #0 /path/to/FileName.php(123): DateTime->__construct() #1

以上のようなエラーが表示された場合、 php.ini の date.timezone を指定しましょう。
日本国内での利用であれば、 Asia/Tokyo とします。

date.timezoneはデフォルトのタイムゾーンを決定する項目です。
DateTimeクラスを利用する際、このタイムゾーンをもとに自動的に時差計算をします。
PHP5.3から設定が必須となりました。
タイムゾーンの一覧は公式マニュアルで確認できます。

Pocket
2 interests