PHP-5.3.0beta1でtimezone関連のWarning
PHP-5.3.0beta1を動かすと、strtotimeを使った際にWarningが出る。
$ php -r 'print(strtotime("2009/01/01 00:00:00"));'
PHP 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 Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. strtotime() Command line code:1
いわれたとおりに
$ php -r 'date_default_timezone_set("Asia/Tokyo");
print(strtotime("2009/01/01 00:00:00"));'
date_default_timezone_set()関数を使うと何もいわれない。また、php.iniを
[Date] ; Defines the default timezone used by the date functions date.timezone = 'Asia/Tokyo'
のように変更すると何もいわれなくなる。これが正しいかどうかは不明。ググレカスにお伺いを立てると結構ヒットする。知らなかったなあ。
Popularity: 4% [?]

Comments
[...] http://selfkleptomaniac.org/archives/1033 [...]