ivan-chkv/yii2-jstimezonedetect

This package is abandoned and no longer maintained. No replacement package was suggested.

Yii 2 jsTimeZoneDetect Asset

2.0.2 2016-12-02 05:05 UTC

README

Yii 2 jsTimeZoneDetect Asset

https://pellepim.bitbucket.io/jstz/

Configuration

<?php

$timeZone = yii\jstimezonedetect\TimeZone::detect(); 

return [
    'timeZone' => $timeZone,
    'components' => [
        'formatter' => ['defaultTimeZone' => $timeZone],
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'on afterOpen' => function (yii\base\Event $event) {
                /* @var $db yii\db\Connection */
                $db = $event->sender;
                $db->createCommand('SET time_zone = :timeZone;', ['timeZone' => date('P')])->execute();
            }
        ]
    ]
];