date関数やstrtotime関数を使ったときにWarningが出る問題

Warningの内容

  • strtotimeの場合
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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in 該当ファイルの箇所

解決方法

MacBookAir:MacOS X 10.7.2(Lion)
での、php.iniの場所が以下。

/etc/php.ini.default

この中の1000行目辺りにある、

;date.timezone =

を以下のように修正して解決。

date.timezone = Asia/Tokyo

もしくは…


date関数を使う前に、以下を書いておく。

<?php

date_default_timezone_set('Asia/Tokyo');