Hi all,
Not very sure if it’s a bug or not. I try to change my default timezone in app.php like this:
return [
...
'App' => [
'namespace' => 'App',
'encoding' => env('APP_ENCODING', 'UTF-8'),
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),
'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'Europe/Brussels'), // <= this rule has been changed
'base' => false,
'dir' => 'src',
'webroot' => 'webroot',
'wwwRoot' => WWW_ROOT,
//'baseUrl' => env('SCRIPT_NAME'),
'fullBaseUrl' => false,
'imageBaseUrl' => 'img/',
'cssBaseUrl' => 'css/',
'jsBaseUrl' => 'js/',
'paths' => [
'plugins' => [ROOT . DS . 'plugins' . DS],
'templates' => [ROOT . DS . 'templates' . DS],
'locales' => [RESOURCES . 'locales' . DS],
],
],
...
];
With this setting, when I debug this code:
debug(date('Y-m-d H:i:s'));
debug(FrozenTime::now());
I still got these values:
ROOT\plugins\Blog\src\Controller\ArticlesController.php (line 44)
'2022-08-15 17:52:32'
ROOT\plugins\Blog\src\Controller\ArticlesController.php (line 45)
object(Cake\I18n\FrozenTime) id:0 {
'time' => '2022-08-15 17:52:32.791773+00:00'
'timezone' => 'UTC'
'fixedNowTime' => false
}
The time is still 2 hours behind my own time zone (Europe/Brussels) and as you can see, the timezone is still ‘UTC’.
I also tried to change the .env file:
export APP_NAME="cms"
export DEBUG="true"
export APP_ENCODING="UTF-8"
export APP_DEFAULT_LOCALE="en_US"
export APP_DEFAULT_TIMEZONE="Europe/Brussels" // <= this rule has been changed
But with this code, the timezone is still ‘UTC’. Even after I cleared the cache…
Do you think this is a bug? The only thing that helps is to change the initialize method in AppController.php like this:
public function initialize(): void
{
parent::initialize();
date_default_timezone_set('Europe/Brussels'); // <= this rule has been added
}
But this is not the way I want it to work
Any idea(s)?
Thanks!