Support the ongoing development of Laravel.io →
posted 11 years ago
Eloquent

Im not sure, but i think in the past, when i used timestamps() in my migration, laravel automatically created "created_at" and "updated_at". That is still the case, but in the past i think with the Insert-Function of eloquent (MyModel::insert(array(...))) also the created_at was set automatically… but now it is not set anymore. Do i have to set the time also in the array?

Last updated 3 years ago.
0

I also noticed this one. I created them manually instead on my schema builder and added

->default(DB::raw('CURRENT_TIMESTAMP'));
Last updated 3 years ago.
0

Found it out :) … instead of insert i have to use create.

Last updated 3 years ago.
0

Eloquent only use updated_at and created_at if $timestamps is set to true in your models. If you don't want to use it in your model set it to false.

Read http://laravel.com/docs/eloquent#timestamps

class Model extends Eloquent {
    ...
    public $timestamps = false;
    ...
}

One thing you should never do is to rely on DB::raw('CURRENT_TIMESTAMP') as your database (MySQL) doesn't know what timezone you have set in your config.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.