Posts Learn Components Snippets Categories Tags Tools About
/

How to Add Timezones Fields in Laravel Migration

Learn how to add timezone field in Laravel migration to replace the commonly used timestamp type.

Created on Aug 01, 2021

871 views

To add a timezone field in Laravel migration, you can specify the field/column to have timezone by using "timestampsTz()" method. Since the common way is to use "timestamps()" you can replace it to use the timezone method.

Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->timestampsTz();
});

Once you have run the migration, now you will be able to specify the timezone for the timestamp.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)