Dwight Watson's blog

Timezones in Lumen

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

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 by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.