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.
UTC is the default after 5.4. 0.
The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script.
The getDefault() method of TimeZone class in Java is used to know the default TimeZone for this system or host. This may vary in according to the implementation in different environment. Parameters: The method does not take any parameters. Return Value: The method returns the default TimeZone of the host.
In my installation BY DEFAULT I had realy weird configuration. File /etc/php/7.3/fpm/pool.d/www.conf had such a setting at the end of the file
php_admin_value[date.timezone] = UTC
It lead to timezone setting being ignored in php.ini and default system timezone being ignored.
The problem seems to be be with php-fpm processes that lingers around and refers to the old php.ini file settings. This worked for me:
Get the process ids for php-fpm
root@thiru:/etc/php5/fpm/conf.d# ps aux | head -1 && ps aux | grep php-fpm | grep -v grep
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 32650 0.0 0.5 86624 17032 ? Ss 21:44 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data 32652 0.0 0.1 86624 4700 ? S 21:44 0:00 php-fpm: pool www
www-data 32653 0.0 0.1 86624 4704 ? S 21:44 0:00 php-fpm: pool www
Kill the processes. Starting with the master.
kill -9 32650
kill -9 32652
kill -9 32653
Start php-fpm using the init script
service php5-fpm start or /etc/init.d/php5-fpm start
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
).
List of supported timezone values: http://php.net/timezones
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With