For your first proposition: I add that timezone so that the formatter doesn’t convert the date to the application timezone, I am using the formatter just to add the name of the day(sunday…) and month(june…) in the application language(en,fr,ru,hi,es,…), It does the translate well. If there is another way that can support different languages, I can use it.
For the second proposition: I use an extension, here is the configuration in component:
'timezone' => [
'class' => 'yii2mod\timezone\Timezone',
'actionRoute' => '/site/timezone' //optional param - full path to page must be specified
],
and bootstrap:
‘bootstrap’ => [‘log’,‘timezone’,
],
so it does it. The only on problem is those nonsense words that it is add, if I remove the Yii::$app->getTimezone(), it’s working well(but the problem is, it is converte the parameter date I passs to the app timezone.
But sometimes you cannot set a default time zone because you have users all around the world. Because of that, as I have earlier said, you have to change a time zone dynamically.