As a developer, whether you are working on a fresh project or modifying an existing Laravel application, it may sometimes be important for the application’s timezone to match the current location’s timezone.
Laravel has a default timezone which is set to UTC.
There are two main ways to change the timezone.
From your project root directory, open the config
directory.
Edit the app.php
file next and the timezone
value from UTC to the desired timezone from the list of available timezones.
// just change only the timezone
'timezone' => 'Asia/Singapore',
Make a modification in the .env
file to specify the timezone as follows:
APP_TIMEZONE='Asia/Singapore'
Then, add the following in the app.php
file:
'timezone' => env('APP_TIMEZONE', 'UTC'),
// The second parameter UTC is set as the default timezone value
This involves making some changes to the app.php
file. Once those changes have been made, it is important to run the following command to clear the config settings stored in the cache.
php artisan config:clear
RELATED TAGS
CONTRIBUTOR
View all Courses