メモ:PHP Warning: date()

新しく構築したサーバにsymfonyでモジュールを作成した際、以下のような警告が

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.


date関数を使う際に、デフォルトのタイムゾーンが定義されていないために発生する警告らしいです。

php.iniにデフォルトタイムゾーンを設定

$vi /etc/php.ini

[Date]
; Defines the default timezone used by the date functions
date.timezone = Asia/Tokyo

Apache再起動

/etc/rc.d/init.d/httpd restart

参考URL:date.timezoneを使えと怒られた