I have an CakePHP 3.4 app with:
- PHP Timezone UTC
- MySQL Timezone UTC
Now i would like to set the default timezone the user can sees to Europe/Brussels.
(I intend to change this at a later moment to the geographical location of the user.)
Howe can i do this?
in configuration https://book.cakephp.org/3.0/en/orm/database-basics.html#configuration:
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'my_app',
'password' => 'sekret',
'database' => 'my_app',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
$time->timezone = 'Europe/Paris';
Setting the default data source to a different timezone would set the time zone for all users. As i need to change the timezone by user, this is not really wat i need.
And would this manner not mean that you will have to cache for every timezone??
Setting the timezone interactively would mean that the timezone needs to be individually set for every Date/Time object.
It may work but i’m looking for an easier way changing all my controller’s and templates/views is not something look forward to.
is there not a way to allow CakePHP to change all time values outgoing/incoming by X hours without changing the DB time zone??
Did you ever solved this?