From the daily archives: 土曜日, 8月 13, 2011

PHPの設定がデフォルトのままの場合、日付関係の関数(date()とか)を使うとwarningを出してきます

↓エラー文
[plain]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 /xxx.php on line xxx[/plain]

これをなくすにはphp.iniでデフォルトのtimezoneを設定すればOKです

  1. php.iniを開く[plain]sudo vi /etc/php.ini[/plain]
  2. [Date]の部分を探し、次のように修正する[plain][Date]
    ; Defines the de……
    ; http://www.php……
    date.timezone = Asia/Tokyo
    [/plain]
  3. apacheの再起動[plain]sudo /etc/init.d/httpd restart[/plain]