Skip to main content

Your database timezone set to "+00:00" by default with Lumen

1 min read

When running a command-line with artisan, I had time-dependent queries which never returned the affected rows I was expecting. I had this command precisely running at 00:01 every morning. 

By scheduling the task three hours later or by launching it manually in the morning, I was provided with the correct results. That's how I figured something was off with regards to the application timezone.

At first, I set the environment variable APP_TIMEZONE value to Europe/Paris in .env according to my context of execution. Unfortunately, it was not the solution to my problem.

Since we're dealing with open source code, why not exploring the vendors?

grep -rn timezone ./vendor

resulting in this specific match (among many others)

./vendor/illuminate/database/Connectors/MySqlConnector.php:43:        if (isset($config['timezone'])) { 

The following keywords submitted to DuckDuckGo led me to the right solution :

The following setting was missing from my application .env file