Change timezone in laravel

go to the file config/app.php and look for this entry:

/*
|--------------------------------------------------------------------------
| 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' => 'Asia/Tehran', //There will be default 'UTC' here

As you can see, UTC is a default value for Laravel. So you can easily change it here to, like:

'timezone' => 'Asia/Tehran', - See full list PHP Supported Timezones

After changes app.php you should run this command php artisan config:cache


After update app.php run below command and check

php artisan config:cache
php artisan cache:clear

You can create below type of route for clear cache in laravel

Route::get('/clear-cache', function() {

    $configCache = Artisan::call('config:cache');
    $clearCache = Artisan::call('cache:clear');
    // return what you want
});

Tags:

Php

Laravel