yii2mod / yii2-timezone
Timezone helper
Installs: 10 476
Dependents: 1
Suggesters: 0
Security: 0
Stars: 15
Watchers: 5
Forks: 3
Open Issues: 0
Type:yii2-extension
This package is not auto-updated.
Last update: 2024-10-26 18:22:41 UTC
README
Timezone component for Yii 2
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yii2mod/yii2-timezone "*"
or add
"yii2mod/yii2-timezone": "*"
to the require section of your composer.json.
Usage
Currently firefox and edge browsers are not supported.
Once the extension is installed, simply add component to your main config file:
'bootstrap' => [ 'timezone' ] ..... 'components' => [ 'timezone' => [ 'class' => 'yii2mod\timezone\Timezone', 'actionRoute' => '/site/timezone' //optional param - full path to page must be specified ], ]
Then add new action to any controller (SiteController by default)
public function actions() { return [ 'timezone' => [ 'class' => 'yii2mod\timezone\TimezoneAction', ], ]; }
After configuration you can use Yii::$app->timezone->name
to get current user's timezone.