Timezone.php
public function registerTimezoneScript($actionRoute)
    {
        Yii::$app->on(Controller::EVENT_BEFORE_ACTION, function ($event) use ($actionRoute) {
            $view = $event->sender->view;
            $js = <<<JS
                var timezone = '';
                var timezoneAbbr = '';
                try {
                    var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
                    var timezoneAbbr = /\((.*)\)/.exec(new Date().toString())[1];
                }
                catch(err) {
                    console.log(err);
                }
                $.post("$actionRoute", {
                    timezone: timezone,
                    timezoneAbbr: timezoneAbbr,
                    timezoneOffset: -new Date().getTimezoneOffset() / 60
                });
JS;
            $view->registerJs($js);
        });
    }
public function registerTimezoneScript($actionRoute)
    {
        Yii::$app->on(Controller::EVENT_BEFORE_ACTION, function ($event) use ($actionRoute) {
            $view = $event->sender->view;
            $js = <<<JS
                var timezone = '';
                var timezoneAbbr = '';
                try {
                    var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
                    var timezoneAbbr = /\((.*)\)/.exec(new Date().toString())[1];
                }
                catch(err) {
                    console.log(err);
                }
                $.post("$actionRoute", {
                    timezone: timezone,
                    timezoneAbbr: timezoneAbbr,
                    timezoneOffset: -new Date().getTimezoneOffset() / 60
                });
JS;
            $view->registerJs($js);
        });
    }
Registering script for timezone detection on before action event
@param $actionRoute