Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - Change created_at to use unix timestamp

Tags:

php

laravel-4

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,

like image 783
maximus 69 Avatar asked Oct 28 '14 07:10

maximus 69


1 Answers

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');
like image 181
Sudhir Bastakoti Avatar answered Oct 27 '22 08:10

Sudhir Bastakoti