How to disable model timestamps in Laravel?

Today now in this post i will show you How to disable model timestamps in Laravel? Sometimes we may need to disable created_at and updated_at timestamps on the Model inLaravel application. So we can easily do this by using the $timestamps variable of model. It is a very small things but it is very important to understand and need to know how to use it. We can also use this in any version laravel 6, laravel 7 and laravel 8 application.

When we create a new item or user by using the model at that time the created_at and updated_at column set the default time by default but we can prevent to set it false value of $timestamps variable.

Here I am creating a new records by using create method of model as like as bellow example:


Ok, above code will simply to add a new records on items table also with current timestamps value in created_at and also updated_at. But we can prevent by add $timestamps variable value is false. So we can do by using our model will be like this way:

namespace App;
use Illuminate\Database\Eloquent\Model;
class Item extends Model
    public $fillable = ['title'];
    public $timestamps = false;

Read Also: How to implement infinite ajax scroll pagination in Laravel?

Thanks for read. I hope it help you. For more you can follow us on facebook


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →