Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

laravel
communitycreator

How to change the timezone in a Laravel application

Chinweuba Elijah Azubuike

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.

Changing the timezone

There are two main ways to change the timezone.

Option 1

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',

Option 2

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

laravel
communitycreator

CONTRIBUTOR

Chinweuba Elijah Azubuike
RELATED COURSES

View all Courses

Keep Exploring