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](http://4.bp.blogspot.com/-SLJP_9qgldc/VcdSMcyO8XI/AAAAAAAANoA/8Roi9nPXVfg/s1600/Image%2B6.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', ], ```