There's a Centos6.3 system. Apache 2.2.15 + mod_fcgid + PHP 5.3.3

There's a problem with date.timezone value. It's mentioned in the global /etc/php.ini like this:

date.timezone = "Europe/Moscow"

And doesn't mentioned in user's local php.ini. As a result, I'm getting lot's of warnings like:

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 ...

Including the date.timezone parameter into the user's php.ini solves the problem, but I don't think, that it's the best solution.

Maybe someone have faced this problem and can give an advice?


P.S. Creating /etc/php.d/timezone.ini with the timezone info aslo does nothing:(

  • What's the output of php -i, and how does it compare to php -i -c /path/to/user.ini. We're looking for Configuration File (php.ini) Path, Loaded Configuration File, and Scan this dir for additional .ini files settings. – emcconville Oct 25 '12 at 21:00
  • From root: php -i | less Configuration File (php.ini) Path => /etc; Loaded Configuration File => /etc/php.ini; Scan this dir for additional .ini files => /etc/php.d; Additional .ini files parsed =>; php -i -c /path/to/users/php.ini | less Configuration File (php.ini) Path => /etc; Loaded Configuration File => /var/www/php-bin/badho159/php.ini; Scan this dir for additional .ini files => /etc/php.d; Additional .ini files parsed => – mega.venik Oct 25 '12 at 21:10
  • Sorry for the formatting:( – mega.venik Oct 25 '12 at 21:14

You will need to add the date.timezone record for each user's ini file. After some experiments, it appears that date timezone will default to global value, but still issue the E_NOTICE and/or E_STRICT or E_WARNING.

Testing global setting

bash~> php -r 'print ini_get("date.timezone").PHP_EOL;'

bash~> php -r 'print date_default_timezone_get().PHP_EOL;'

Testing user.ini without date.timezone set

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


The only other alternative would be to require each application to set the default timezone programmatically, but that's unrealistic & much more effort.

if(!ini_get('date.timezone')) {
| improve this answer | |
  • Hi! Sounds interesting. But I've tested it on my server and get the same result: We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in and it shows Europe/Helsinki. I don't know, what is it's choice depends on, but I have EEST global timezone on my server. What is yours? Could you please repeat the test with another timezone in /etc/php.ini? – mega.venik Oct 26 '12 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.