I want to change the timezone in my Laravel / Lumen application. I've tried to change the timezone in my .env file but it did not work. Could someone guide me please?
In Laravel you can change the timezone in the app.php configuration file. This file is located in the following path:
config/app.php
You can insert all PHP supported Timezones or Coordinated Universal Time formats. This will work for Laravel and Lumen.
/*
|-------------------------------------------------------------------
| Application Timezone
|-------------------------------------------------------------------
|
| Here you may specify the default timezone for your application,
| which will be used by the PHP date and date-time functions. We have | gone ahead and set this to a sensible default for you out of the
| box.
|
*/
'timezone' => 'Europe/London',
You can also read or change the timezone on runtime:
Get timezone in Laravel / Lumen:
Config::get('app.timezone');
Change the timezone on runtime in Laravel / Lumen:
Config::set('app.timezone','UTC');