有一个Centos6.3系统。 Apache 2.2.15 + mod_fcgid + PHP 5.3.3
date.timezone值有问题。 这是在全球/etc/php.ini提到的:
date.timezone = "Europe/Moscow"
并没有在用户的本地php.ini中提到。 结果,我得到很多的警告,如:
Warning: date() [function.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 'Europe/Helsinki' for 'EEST/3.0/DST' instead in ...
包括date.timezone参数到用户的php.ini解决了这个问题,但我不认为,这是最好的解决scheme。
也许有人遇到这个问题,可以给个build议?
谢谢!
PS创build/etc/php.d/timezone.ini与时区信息aslo没有:(
您将需要为每个用户的ini文件添加date.timezonelogging。 经过一些实验,看来date时区将默认为全局值,但仍会发出E_NOTICE和/或E_STRICT或E_WARNING 。
testing全局设置
bash~> php -r 'print ini_get("date.timezone").PHP_EOL;' Europe/Moscow bash~> php -r 'print date_default_timezone_get().PHP_EOL;' Europe/Moscow
在没有设置date.timezone情况下testinguser.ini
bash~> php -c /path/to/user.ini -r 'print ini_get("date.timezone").PHP_EOL;' "" bash~> php -c /path/to/user.ini -r 'print date_default_timezone_get().PHP_EOL;' Warning: ... We selected 'Europe/Moscow' for 'EEST/4.0/DST' instead in Command line code on line 1 Europe/Moscow
唯一的另一种select是要求每个应用程序以编程方式设置默认的时区,但这是不现实的,更多的努力。
if(!ini_get('date.timezone')) { date_default_timezone_set('Europe/Moscow'); }