How to set Indian Timezone in Laravel?
In this post, I will show you how to set indian timezone in laravel application.
By default, Laravel uses the UTC timezone. For Indian users, we can set the timezone to `Asia/Kolkata`. There are two ways to configure the timezone:
Example 1: Update timezone from .env file
.env
APP_TIMEZONE="Asia/Kolkata"
Example 2: Update timezone from config file
You can directly change timezone from config file like the following way:
config/app.php
'timezone' => 'Asia/Kolkata',
You can test it with the following route code:
Route::get('/', function () {
dd(now());
});
You will see the output like this way:
Illuminate\Support\Carbon @1733495164 {#278 â–¼ // routes/web.php:11
#endOfTime: false
#startOfTime: false
#constructedObjectId: "00000000000001160000000000000000"
-clock: null
#localMonthsOverflow: null
#localYearsOverflow: null
#localStrictModeEnabled: null
#localHumanDiffOptions: null
#localToStringFormat: null
#localSerializer: null
#localMacros: null
#localGenericMacros: null
#localFormatFunction: null
#localTranslator: null
#dumpProperties: array:3 [â–¶]
#dumpLocale: null
#dumpDateProperties: null
date: 2024-12-06 19:56:04.452330 Asia/Kolkata (+05:30)
}
I hopw it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Datatables Relationship with Filter Column Example
- Laravel Eloquent Find with Trashed Record Example
- How to Add Toastr Notification in Laravel 11?
- Laravel 11 Store JSON Format Data in Database Tutorial
- How to Integrate AdminLTE 3 in Laravel 11?
- Laravel 11 Event Broadcasting Tutorial
- Laravel 11 Confirm Box Before Delete Record from Database
- Laravel 11 Localization | Create Multi Language in Laravel 11
- Laravel 11 Client Side Form Validation using JQuery
- Laravel 11 Pagination Add Query String Example
- How to Use Quill Rich Text Editor in Laravel 11?
- Laravel 11 Reverb Real-Time Notifications Example