Timezones in Lumen

June 17, 2015

Because there aren’t any configuration files with Lumen, you now approach setting up the application using environment variables. If you dig into Lumen’s source code you can find the configuration files where the framework attempts to load options from the environment and then falls back to it’s defaults. However, the timezone option isn’t actually listed in the config/app.php configuration file.

No matter however, as you’ll find in the Lumen Application constructor it will also attempt to load the timezone from the environment:

 * Create a new Lumen application instance.
 * @param  string|null  $basePath
 * @return void
public function __construct($basePath = null)
    date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));

    $this->basePath = $basePath;

So, setting the timezone up is as easy as popping APP_TIMEZONE into your .env configuration file as you normally would.


A blog about Laravel & Rails,
written by Dwight Watson.