2015年8月9日 星期日

Laravel 5 資料庫timezone設定

原本在設定database的timezone的設定方式是採取 ```php 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'options' => [ PDO::MYSQL_ATTR_INIT_COMMAND => 'SET time_zone = "+08:00"' ], ], ``` 後來卻在laravel的原始碼發現 ![Alt text](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_u-41FbGyPsJq6Z6AqMqSbCalwbp1QGNb5pazM_r-74k1coiFCRQE_2sRby6ZdxDPAumL7GPPKDJwlthyphenhyphenlrA4nujOquoQk2pRyf-5Tbjtm0iYv2N3NJyZz9ozEzxtyR69BtKVJuk7lZSL/s1600/Image+6.png) 所以timezone的設定只要這樣寫就可以 ```php 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'timezone' => '+08:00', ], ```

沒有留言:

張貼留言