How to set Indian Timezone in Laravel?

By Hardik Savani December 6, 2024 Category : 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...

Tags :
Shares