As a developer, you may encounter situations where you need to display date and time in different time zones within your Laravel application. By default, Laravel uses the UTC timezone for all date and time operations. However, it’s often necessary to change this default timezone to a different one, based on the user’s location or the specific requirements of the application. In this post, we’ll explore how to change america time zone in a laravel application. We’ll cover the different ways to set the timezone, So without any late lets get started…

Methods for Changing America Time Zone in Laravel App :
- Method 1: How to Change America Time Zone in Laravel App By Manually
- Method 2 : Setting America Time Zone in Laravel App from .env File
- Method 3 : Setting America Time Zone in Laravel Dynamically
Method 1: How to Change America Time Zone in Laravel App By Manually :
Step 1 : Open Config/app.php file :
Open app.php file which is present in config directory from your root folder, As shown below screenshot.

By default, timezone is set to UTC,
Step 2 : Replace UTC with your timezone :
Lets replace the default time zone,
I would like replace it with America/New_York, as shown below figure.

For complete list of time zones in php, You can check here .
Step 3: Clear the Config Cache
Run the following command in the terminal to clear the cache:
php artisan config:clear
Step 4: Print in controller or view
$current_date_time=Carbon\Carbon:now();
echo $current_date_time;
Method 2 : Setting America Time Zone in Laravel App from .env File:
Step 1 : Open .env file from your project root directory, Add APP_TIMEZONE global variable as shown in the below screenshot.

Step 2 : Now, Add APP_TIMEZONE in the app.php file, as shown in the below screenshot

Step 3 : 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
Method 3 : Setting America Time Zone in Laravel Dynamically :
Setting the timezone dynamically in a Laravel application allows you to change the timezone at runtime, based on user input or other factors. This approach can be particularly useful for applications with users in different time zones or those that need to handle multiple time zones for other reasons. In this approach, the timezone is not set globally in the application configuration but rather on a per-request basis, providing more flexibility and customization.
So, Lets see how to set America Time Zone in Laravel by Dynamically.
Step 1: Calling the php timezone function
In this method, you just need to call the PHP time zone function date_default_timezone_set in your controller or view.
date_default_timezone_set('Europe/Paris')
$current_date_time=Carbon\Carbon:now();
echo $current_date_time;
Note the timezone will only be affected for the current request.
Step 2 : Clear cache if it doesn’t work
For some reason, if it may not get affected,Then try to clear the cache.
php artisan cache:clear
php artisan config:clear
Frequently Asked Questions
What is USA time zone for laravel ?
For complete list of time zones in php, You can check here .
How to set timezone laravel ?
Method 1: How to Change America Time Zone in Laravel App By Manually
Step 1 : Open Config/app.php file :
Step 2 : Replace UTC with your timezone :
Step 3: Clear the Config Cache
Step 4: Print in controller or view
Laravel timezone list ?
For complete list of time zones in Laravel / php, You can check here .
Laravel set timezone dynamically
We can do this by calling the php timezone functiondate_default_timezone_set('Europe/Paris') $current_date_time=Carbon\Carbon:now(); echo $current_date_time;
How to get current timezone in Laravel
You can print current timezone from a controller or view as shown below$current_date_time=Carbon\Carbon:now();
echo $current_date_time;
Conclusion
I hope you understand how to manage timezones in your Laravel application and also able to apply these techniques on your own projects.
Check out my Laravel Ecommerce Project With Complete Source Code – 2022
If you are having any doubts, Please feel free to comment below and share your thoughts.