How can I set Timezone in lumen 5.2?
None of the responses I've read in a lot of forums solves the problem, because in the file /vendor/laravel/lumen-framework/config/database.php there is this line:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', 3306), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => env('DB_CHARSET', 'utf8'), 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'), 'prefix' => env('DB_PREFIX', ''), **'timezone' => env('DB_TIMEZONE', '+00:00'),** 'strict' => env('DB_STRICT_MODE', false), ],
You need to rewrite this config file. Create a database.php file in config folder. Then copy all the content without the timezone line. This works for me.
This is pretty easily done and shown in their documentation page:
To set configuration values at runtime, pass an array to the config helper:
config(['app.timezone' => 'America/Chicago']);
Alternatively, in app/config.php
:
'timezone' => 'UTC',