Posts Learn Components Snippets Categories Tags 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

21 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.

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More