Set PHP timezone


Check current timezone

$ php -r "echo ini_get('date.timezone');"
>>>

Check what date PHP would print (on cli)

$ php -r "echo date('r');"
>>> Fri, 22 Nov 2019 14:28:03 +0000

Set the timezone in the PHP config file

Set the value America/Sao_Paulo in the directive date.timezone. The config file location varies according to the PHP installation method.

$ echo date.timezone=America/Sao_Paulo | sudo tee -a /etc/php/conf.d/my-customs.ini

Check the timezone and current date again

$ php -r "echo ini_get('date.timezone');"
>>> America/Sao_Paulo

$ php -r "echo date('r');"
>>> Fri, 22 Nov 2019 11:51:25 -0300

References

php