おしブロ from STONEWEB

おしい県でWebに携わって働く人のブログ from ストーンウェブ。IT&Web界隈に関する役に立ちそうなことをまとめていきます。2013年1月運営開始。

移転しました。

約3秒後に自動的にリダイレクトします。

Macのローカル開発環境にCakePHP2.3.0をインストールした時のメモ。(タイムゾーンのWarningを消す方法)

 「http://(インストールしたディレクトリ)」

にアクセスすると、こんな画面が表示されます。

 

f:id:lord_cashew:20130209034734p:plain

 

何やらエラーっぽいメッセージ(Warning)が表示されていますが、そのメッセージの内容はこんな感じです。

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 'Asia/Tokyo' for 'JST/9.0/no DST' instead in /var/www/html/blog/lib/Cake/Cache/CacheEngine.php on line 59 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 'Asia/Tokyo' for 'JST/9.0/no DST' instead in /var/www/html/blog/lib/Cake/Cache/CacheEngine.php on line 59

 

要するに「PHPでデフォルトのタイムゾーンの設定が行なわれていないぞー」という意味です。

これを解消するには、php.iniファイルを編集する方法があるのですが、今回はCakePHPのファイルを編集する方法で解消しました。

 

f:id:lord_cashew:20130209033728p:plain

 

(CakePHPをインストールしたディレクトリ)\lib\Cake\Cache\CacheEngine.php

を開いて、59行目に「date_default_timezone_set('Asia/Tokyo');」を追加します。

f:id:lord_cashew:20130209033812p:plain

 

もう一度アクセスし直してみると、Warningメッセージが消えています。

 

© STONEWEB