Warning: strtotime(): It is not safe to rely on the system’s timezone settings.

さくらのVPSサーバーで、新しくCakePHPをセットアップして動くようにする過程で、TimezoneのWarningメッセージが出てきました。

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 /www/lib/Cake/Cache/CacheEngine.php on line 45 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 /www/lib/Cake/Cache/CacheEngine.php on line 45

Warning (2): 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 [CORE/Cake/Log/Engine/FileLog.php, line 68]

メッセージが長いのでなんだかすごい勢いで怒られているような気がしますけど、これはPHP側
でタイムゾーンの設定がなされていない、という問題を指摘してくれているものです。

広告

「とりあえずシステムのタイムゾーンを参照しておくけど、安全性に問題があるからちゃんとしなさいよ」と。

php.iniにタイムゾーンを設定
php.iniを開き、デフォルトのタイムゾーン「date.timezone」を修正しましょう。

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
 
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
date.timezone =Asia/Tokyo

;date.timezone =
がコメントアウトされてしかも空白なので、Asia/Tokyoを上記のように設定しておきます。
Apacheをリスタートして、これでOK。

About: dacelo


1 thought on “Warning: strtotime(): It is not safe to rely on the system’s timezone settings.”

  1. Pingback: dacelo

Leave a Reply

Your email address will not be published. Required fields are marked *