Change Timezone in Laravel / Lumen

Software

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?

PHP Programming OpenSource Question created: 2020-08-02 08:02 tecnick

5

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');
answered 2020-08-02 08:15 feedMeNow