Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yii2mod/yii2-timezone
Timezone detector
https://github.com/yii2mod/yii2-timezone
yii2 yii2-extension yii2-timezone yii2-timezone-detector
Last synced: 3 days ago
JSON representation
Timezone detector
- Host: GitHub
- URL: https://github.com/yii2mod/yii2-timezone
- Owner: yii2mod
- License: mit
- Created: 2015-03-27T19:30:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-01T14:37:21.000Z (about 8 years ago)
- Last Synced: 2024-08-10T23:24:26.552Z (about 2 months ago)
- Topics: yii2, yii2-extension, yii2-timezone, yii2-timezone-detector
- Language: PHP
- Size: 4.88 KB
- Stars: 15
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Yii 2 Timezone
==============
Timezone component for Yii 2[![Latest Stable Version](https://poser.pugx.org/yii2mod/yii2-timezone/v/stable)](https://packagist.org/packages/yii2mod/yii2-timezone) [![Total Downloads](https://poser.pugx.org/yii2mod/yii2-timezone/downloads)](https://packagist.org/packages/yii2mod/yii2-timezone) [![License](https://poser.pugx.org/yii2mod/yii2-timezone/license)](https://packagist.org/packages/yii2mod/yii2-timezone)
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist yii2mod/yii2-timezone "*"
```or add
```json
"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:
```php
'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)
```php
public function actions()
{
return [
'timezone' => [
'class' => 'yii2mod\timezone\TimezoneAction',
],
];
}```
After configuration you can use ``` Yii::$app->timezone->name``` to get current user's timezone.