Skip to content

Instantly share code, notes, and snippets.

@mtangoo
Forked from SilverFire/config.php
Created October 5, 2016 08:01
Show Gist options
  • Save mtangoo/94f0618b8e14ec7750ee9b9237ccc76d to your computer and use it in GitHub Desktop.
Save mtangoo/94f0618b8e14ec7750ee9b9237ccc76d to your computer and use it in GitHub Desktop.
Yii2 set timezone for DB connection
<?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