Skip to main content

How to Change Timezone in Laravel

Laravel makes it simple and straightforward to change the timezone of your application. Timezones can be set at the application level, meaning all dates displayed by your application will be converted to the specified timezone. Of course, you may also set the timezone per request if needed.

For example, if you are displaying content from multiple timezones on a single page. To set the timezone at the application level, open your app and access config/app.php file and locate the timezone option in the app configuration array. You should set this option to a valid PHP timezone string: ‘timezone’ => ‘America/Chicago’.

/*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */

    'timezone' => 'America/Chicago',

Save the file and Laravel will automatically use the new timezone for all date/time operations in your application.

Another way is to set the timezone in .env file and call the variable in config/app.php.

//in .env
APP_TIMEZONE='Asia/Bangkok'

//in config/app.php 
'timezone' => env('APP_TIMEZONE', 'UTC'),

By continuing to use the site, you agree to the use of cookies.