PHP5.3のtimezone関連のエラー (php.ini)




PHPを5.3.×にアップグレードしてみたら、timezone関連にエラーが出るようになりました。
PHPからMySQLにDatetime型でデータを登録していたのですが、何故か登録されない・・・
という症状が出て、原因追究したところ
「PHP5.3からはタイムゾーンの設定が必要」
なことがわかりました。

PHPファイルをターミナルから直接叩いてみたところ

下記のようなエラーが出ました。

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/・・・・

timezoneの設定方法

php.iniの[Date]のところに下記を追加します。

date.timezone = Asia/Tokyo

デフォルトだと

[Date]
; Defines the default timezone used by the date functions

となっており、コメントアウトされているようです。




人気記事一覧


関連記事一覧

This entry was posted in Linux and tagged , , , , , , . Bookmark the permalink.

コメントは受け付けていません。