PHPackages                             asmoday74/yii2-timezone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. asmoday74/yii2-timezone

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

asmoday74/yii2-timezone
=======================

This component allows you to automatically determine the temporary zone of the user and set it up in the YII2 settings for the correct operation of temporary representations.

1.0.2(1y ago)02MITPHP

Since Apr 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/asmoday74/yii2-timezone)[ Packagist](https://packagist.org/packages/asmoday74/yii2-timezone)[ RSS](/packages/asmoday74-yii2-timezone/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Yii2 Timezone
=============

[](#yii2-timezone)

This component allows you to automatically determine the temporary zone of the user and set it up in the YII2 settings for the correct operation of temporary representations.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist asmoday74/yii2-timezone "*"

```

or add

```
"asmoday74/yii2-timezone": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

As soon as the component is installed, add the following config to the application settings (web.php for the template "basic", main.php for the "advanced" template):

```
$config = [
    ...
    'bootstrap' => ['log', 'timezone'],
    ...
    'components' => [
        ...
        'timezone' => [
            'class' => asmoday74\timezone\UserTimezone::class,
            'controllerName' => 'timezone', //this is default name
            'defaultTimezone' => 'Europe/Moscow'
        ],
        ...
];
```

Additional information
----------------------

[](#additional-information)

For the correct work with the time received from the database and saved in it, it is recommended to configure the time ward UTC when connecting to the database. For this:

- In PostgreSQL:

```
return [
	'class' => \yii\db\Connection::class,
	'dsn' => 'pgsql:host=localhost;dbname=dbname',
	'username' => 'user',
	'password' => 'password',
	'charset' => 'utf8',
	'on afterOpen' => function($event) {
	    $event->sender->createCommand("SET timezone TO 'UTC'")->execute();
	}
];
```

- In MySQL:

```
return [
	'class' => \yii\db\Connection::class,
	'dsn' => 'mysql:host=localhost;dbname=dbname',
	'username' => 'user',
	'password' => 'password',
	'charset' => 'utf8',
	'on afterOpen' => function($event) {
	    $event->sender->createCommand("SET @@session.time_zone = '+00:00'")->execute();
	}
];
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance47

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

395d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11393255?v=4)[asmoday74](/maintainers/asmoday74)[@asmoday74](https://github.com/asmoday74)

---

Tags

componentextensiontimezoneyii2yii2-componentyii2-extensionyii2extensiontimezone

### Embed Badge

![Health badge](/badges/asmoday74-yii2-timezone/health.svg)

```
[![Health](https://phpackages.com/badges/asmoday74-yii2-timezone/health.svg)](https://phpackages.com/packages/asmoday74-yii2-timezone)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
