「It is not safe to rely on the system's timezone settings.」の警告が表示される場合

カテゴリ:PHP

現象

PHP 5.1.0 以降より date() や strtotime() 関数を実行した際に、タイムゾーンが設定されていない場合に、/etc/httpd/logs/error_log に以下の警告が 大量に出力されます。

PHP Warning:  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 in /var/www/html/hoge/hoge.php on line 42

PHP Warning:  strtotime(): 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 /var/www/html/hoge/hoge.php on line 42

対処方法

/etc/php.ini の [Date] セクションにタイムゾーンを設定する事で解消されます。

公開日時:2018年01月13日 12:41:05

なお、VPS選びで迷ったらこちらの記事で主要VPSのメモリ容量ごとの月額、年額料金を比較していますので、是非参考にしてみてください。

PHPに戻る

このページのトップに戻る