ivan-chkv/yii2-jstimezonedetect

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

Yii 2 jsTimeZoneDetect Asset

Installs: 4 627

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Type:yii2-extension

2.0.2 2016-12-02 05:05 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:59:31 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();
            }
        ]
    ]
];