In this post, I will show you How To Set 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:
How To Set Timezone in Laravel Example
Example 1: Update timezone from .env file
.env
APP_TIMEZONE="Asia/Dhaka"
Example 2: Update timezone from config file
You can directly change timezone from config file like the following way:
config/app.php
'timezone' => 'Asia/Dhaka',
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/Dhaka(+06:00)
}
I hopw it can help you…
You Can Learn How to Delete Multiple Records using Checkbox in Laravel?