maximus 69
maximus 69

Reputation: 1458

Laravel - Change created_at to use unix timestamp

I am working on Laravel 4 application and would like to save the unix timestamp for the created_at and updated_at fields instead of the default timestamp values.

Any suggestions on how I could achieve this?

Regards,

Upvotes: 10

Views: 19084

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

you can just get the timestamp property, as:

$timestamp = $model->created_at->timestamp;

or, you could override the getDateFormat(), and create migration of required fields, as:

$table->integer('created_at');
$table->integer('updated_at');

Upvotes: 18

Related Questions