How to Change Time Zone in Laravel

AuthorSumit Dey Sarkar

Pubish Date13 Apr 2023

categoryLaravel

In this tutorial we will learn how to change time zone in Laravel.

 

How to Change Time Zone in Laravel

You can take the following actions to modify Laravel's time zone:

 

Step 1 - Your Laravel project's config/app.php file should be opened.

 

 

Step 2 - Locate the timezone key and change its value to the desired time zone. You can see a list of supported time zones on the official PHP website by searching on google.

 

 

Step 3 - As an alternative, you can use the config function in your code to set the time zone dynamically. For example, if you need to set the time zone to "America/New_York" (according to you need) then you need to add the following code to your controller.

config(['app.timezone' => 'America/New_York']);

 

Step 4 - You can also set the time zone globally by adding the above code to the boot method of the AppServiceProvider class.

 

That's it! Your Laravel application will now use the specified time zone.

Comments 0

Leave a comment