-
-
Save mtangoo/94f0618b8e14ec7750ee9b9237ccc76d to your computer and use it in GitHub Desktop.
Yii2 set timezone for DB connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| return [ | |
| 'components' => [ | |
| 'db' => [ | |
| 'class' => '\yii\db\Connection', | |
| 'dsn' => 'mysql:host=127.0.0.1;dbname=demo', | |
| 'username' => 'root', | |
| 'password' => '', | |
| 'charset' => 'utf8', | |
| 'on afterOpen' => function($event) { | |
| $event->sender->createCommand("SET time_zone='+00:00';")->execute(); | |
| }, | |
| ], | |
| ] | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment