You can set your app time zone by configuring app.php file in config folder .
To change time zone , modify the value of timezone in app.php file.
This is written in this section
|--------------------------------------------------------------------------
| 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.
|
For me i am using Asia/Dhaka as my application time zone.
In my case (reading a date from a MySQL db in a Lumen 5.1 project) the only solution that worked is using Carbon to set timezone of variables:
$carbonDate = new Carbon($dateFromDBInUTC);
$carbonDate->timezone = 'America/New_York';
return $carbonDate->toDayDateTimeString(); // or $carbonDate->toDateTimeString() for ISO format
Using DB_TIMEZONE=-05:00 in the .env file almost worked but does not handle DST changes.
Using the APP_TIMEZONE=America/New_York in the .env file had no effect on a timezone value retrieved in a Lumen 5.1 webapp from a MySQL database, but it works in Lavarel 5.1.
Also Lumen didn't read at all the [lumen_project]/config/app.php file that I created (it didn't complain when I put a syntax error there).
Using date_default_timezone_set didn't work either.
You just have to edit de app.php file in config directory
Just find next lines
/*
|--------------------------------------------------------------------------
| 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' => 'UTC',
There are two ways to update your code.
1. Please open the file app.php file present in config directory at lool of your project.
Go down the page and check Application Timezone
where you will find
'timezone' => 'UTC',
Here you can add your timezone like
'timezone' => 'Europe/Paris',
If you want to manage your timezone from .env file, then you can add below code in your config.php file.
This is needed to clear the cache of config settings. If you notice that your timestamps are still wrong after changing the timezone in your app.php file, then running the above command should refresh everything, and your new timezone should be effective.
For me the app.php was here /vendor/laravel/lumen-framework/config/app.php but I also could change it from the .env file where it can be set to any of the values listed here (PHP original documentation here).
Open the config/App.php file and update the timezone value with 'Europe/Paris'
/*
|--------------------------------------------------------------------------
| 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/Paris',
Then clear the config cache by running the below artisan command