I need to change the timezone in my Yii2 application to "Europe/Berlin". I've tried to configure it but it doesn't seem to work for me. How can i achieve this?
Running this in my PHP application returns “UTC”.
Yii2 uses UTC as default timezone if the timezone is not configured in your php.ini or in your application configuration file. There are two ways to solve this issue:
1 Solution) You could modify you php.ini and set:
If your are using php-fpm don't forget to restart the fpm service by running this command: “/etc/init.d/php-fpm restart”. In that way the changes in your php.ini file will be permitted.
2 Solution) You could set the timezone directly in your Yii2 configuration file. This will also overwrite the timezone set in the php.ini.
$config = [ 'timeZone' => 'London/Berlin', ... ]