Laravel - Change created_at to use unix timestamp

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

Any suggestions on how I could achieve this?

Hi,

+4
source share
1 answer

you can just get the timestamp property, for example:

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

or you can override getDateFormat () and create the migration of the required fields, for example:

$table->integer('created_at');
$table->integer('updated_at');
+5
source

All Articles