Skip to content

cybercog/yii2-timezone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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/timezone "*"

or add

"yii2mod/timezone": "*"

to the require section of your composer.json.

Usage

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.

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • PHP 100.0%