Can't set default timezone in PHP

Stann picture Stann · May 27, 2011 · Viewed 41.6k times · Source

I've set this in my php.ini file, and restarted php5-fpm process

date.timezone = "UTC"

But phpinfo() script still shows this:

date.timezone   America/New_York    America/New_York

phpinfo() also shows that correct ini file is being used.

I've restarted - but problem persisted. Then I did:

sudo service nginx stop
sudo service apache2 start

and date.timezone is correct when mod-php (apache2) is in use instead of fcgi that is php in nginx.

Answer

KingCrunch picture KingCrunch · May 27, 2011

You probably edited the wrong php.ini. See php_info() (or php -i for the cli interpreter) which one is used. For example on ubuntu (and probably other linux distributions) its /etc/php5/cli/php.ini for the cli-interpreter, /etc/php5/apache/php.ini/ for the one used by Apaches mod_php and /etc/php5/cgi/php.ini used by php5-cgi (which is used by nginx).