Laravel changing timezone not reflecting the correct time

Viewed 16771

I am changing the timezone into Asia/Singapore at config/app.php, but when I try to do a date("Y-m-d H:i:s"); the result is still in UTC.

Is there anything in Laravel that overrides that timezone that I set at config/app.php ?

3 Answers

Just do this:

'timezone' => 'Asia/Singapore'

in config/app.php file and run this 3 command:

php artisan cache:clear

php artisan view:clear and

php artisan config:cache

Hope this helps you!!

Add this in config/app.php file:

'timezone' => 'Asia/Singapore'  

After, run this command:

 php artisan config:cache

At least in the generated application skeleton of Laravel 5.8, maybe other versions too, the timezone setting in config/app.php is 'timezone' => 'UTC', so it will ignore an APP_TIMEZONE in the .env file.

So put an e.g. APP_TIMEZONE='Europe/Berlin' in .env and modify the line in config/app.php to this:

'timezone' => env('APP_TIMEZONE', 'UTC')

Or, when it's sure local, staging and production all run in the same timezone - change only the line in config/app.php to:

'timezone' => 'Europe/Berlin',
Related