VMWareを使ったLinuxのテスト環境を作ったのだが、timezoneに関するPHPのWarningがうるさいので、対策メモ。
コマンドラインから、次のように入力すると、
php -r ‘phpinfo(); | more’
1ページ目に以下のようなWarningが表示される。
PHP Warning: phpinfo(): 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 Command line code on line 1
phpをディストリビューションのものを使っていれば出てこないんだろうけど、最新のバージョン& Zend Framework をyum管理で楽したい場合、外部リポジトリを使うことになり、多分同じ問題が出るんだろうな。
date.timezone か、date_default_timezone_set()関数を使って設定する必要がある。とな。
/etc/php.ini の中に、コメントアウトされた date.timezoneがあるので、コメントを解除して、値をセット。
date.timezone = Asia/Tokyo
Apacheを再起動すればOK