Laravel Changing Timezone Not Reflecting the Correct Time

Laravel changing timezone not reflecting the correct time

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!!

Change timezone in laravel

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
});

How to change timezone using date() and strtotime() in Laravel

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/Kuala_Lumpur as my application time zone.

Here is the appropriate syntax :

'timezone' => 'Asia/Kuala_Lumpur'

list of timezones for PHP

NOTE : run php artisan config:clear to effect this changes

Laravel change timezone

Try to clear the config cache:

php artisan optimize:clear

Laravel lumen is not saving right time zone

Try adding 'timezone' => env('APP_TIMEZONE', "UTC") to your config/app.php and running php artisan cache:clear after that.

Also try adding DB_TIMEZONE=+05:00 to your .env file (adjusted to your UTC offset of course)



Related Topics



Leave a reply



Submit