---
title: How to Set the Timezone in Laravel
url: https://docs.vultr.com/how-to-set-the-timezone-in-laravel
description: Learn how to properly set and configure timezone settings in Laravel applications to ensure accurate date and time handling across your entire project.
publish_date: 2025-04-24T16:09:22.876509Z
last_updated: 2025-04-24T16:09:22.876509Z
author: Jully Achenchi
header_image: https://assets.vultrdevrel.com/docs-main-doc-assets-1/2158/7d1c48ed-c392-415c-a1b8-72b863399483.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

Laravel is a dynamic, object-oriented programming framework based on PHP for building modern, scalable web applications ranging from basic to complex web solutions. It follows the Model-View-Controller (MVC) architectural pattern, allowing you to create maintainable code and applications with its modern PHP syntax.

This article explains how to set the timezone in Laravel. Setting the correct timezone ensures consistent date and time handling in your application, especially when working with databases, logs, and frontend user timestamps.

## Prerequisites

Before you begin, you need to:

* Have access to an [existing instance such as Ubuntu 24.04](https://www.vultr.com/servers/ubuntu) with an active [Laravel project](https://docs.vultr.com/how-to-install-laravel-on-ubuntu-24-04).

## Laravel Timezone Formats

Laravel offers built-in support for timezone management, allowing your application to use accurate date and time values across different regions. Laravel primarily handles time zones using two methods.

* **Application Timezone**: Laravel stores the global default timezone in the `config/app.php` file which influences how Laravel handles date and time across various components like Eloquent, Carbon, and scheduled tasks.
* **User Timezone**: Stores the user's timezone in the database, and retrieves it from user preferences, or by detection via browser settings. Displaying dates in each user's local timezone improves usability, especially in global applications.

## Set the Timezone in Laravel

Laravel uses the `UTC` timezone by default. Follow the steps below to update the timezone in your Laravel application.

1. Navigate to your Laravel project's root directory such as `/var/www/laravelapp`.

    ```console
    $ cd /var/www/laravelapp
    ```

1. Open the `.env` file to manage the timezone for all environments including dev, staging, and production.

    ```console
    $ sudo nano .env
    ```

1. Add the following configuration variable to the file. Replace `America/Aruba` with your desired timezone.
   
    ```php
    APP_TIMEZONE=America/Aruba
    ```
   
    Save and close the file.

    The above configuration variable sets the default timezone you can reference in your Laravel application. Visit the [PHP documentation](https://www.php.net/manual/en/timezones.php) for a list of timezones you can use in your Laravel project.

1. Open the `config/app.php` file to enable the timezone in your Laravel application.

    ```console
    $ sudo nano config/app.php
    ```

1. Find the timezone configuration within the `app.php` file.

    ```php
    'timezone' => 'UTC'
    ```

1. Replace the default `UTC` value with your environment variable.

    ```php
    'timezone' => env('APP_TIMEZONE', 'UTC'),
    ```

    Save and close the file.

    The above configuration sets the timezone in your Laravel application by referencing the `APP_TIMEZONE` variable in your `.env` configuration. Laravel defaults to `UTC` if the variable is missing in your `.env` file.

1. Clear the configuration cache to apply the configuration changes.

    ```console
    $ php artisan config:cache
    ```

    The above command restarts Laravel to use the updated configuration and timezone in your project. Your output should be similar to the one below when successful.

    ```
    INFO  Configuration cached successfully.  
    ```

## Verify the Active Timezone in Laravel

Follow the steps below to create a new route to test the active timezone in your Laravel project.

1. Create a new `web.php` file in your routes directory.

    ```console
    $ nano routes/web.php
    ```

1. Add the following route configuration to the `web.php` file.

    ```php
    Route::get('/timezone', function () {
        return config('app.timezone');
    });
    ```

    Save and close the file.

    The above configuration creates a new `/timezone` route that displays the active timezone in your Laravel application.

1. Send an HTTP request to the `/timezone` path using your Laravel application's URL and verify that it displays your active timezone. Replace `http://127.0.0.1:8000` with your actual application URL.

    ```console
    $ curl http://127.0.0.1:8000/timezone
    ```

    Output:

    ```
    America/Aruba
    ```

## Conclusion

You have updated the default timezone and set a new timezone in your Laravel project. Configuring the correct timezone ensures consistent behavior, reliability and accurate date and time handling. You can dynamically set the timezone in Laravel based on the authenticated user's preferences using middleware or service providers in more advanced applications. For more information and advanced configurations, visit the [Laravel timezone documentation](https://laravel.com/docs/10.x/localization#timezones).
