Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set Timezone in lumen 5.2?

I did not find any relevant information (only tricks) about how to set the default timezone in Lumen 5.2. Is there any clean way to do this?

like image 366
rap-2-h Avatar asked Feb 08 '16 15:02

rap-2-h


People also ask

How do I set lumen time zone?

/** * 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')); ... We see that Lumen will not take any config value, just an env value to set the time zone.

Where can you find a default timezone set in laravel?

In the laravel project open the file config/app. php , you will notice the 'timezone' => 'UTC', by default, timezone is set to UTC.


1 Answers

In Lumen 5.2 the Application class actually reads from a APP_TIMEZONE environment variable.

You can easily set timezone via a .env file using or setting the environment variable on your server:

APP_TIMEZONE=UTC
like image 191
edgji Avatar answered Oct 09 '22 05:10

edgji