For Laravel 4:
- override the freshTimestamp () method in your Eloquent model
- use integers in migration file instead of timestamp
models /product.php
class Product extends Eloquent { protected $table = 'products'; public function freshTimestamp() { return time(); } }
Laravel 4 also mutates all dates / timestamps for Carbon instances (Documented here )
This means that you also need to overwrite the getDates() method to prevent carbon destroying your timestamp before inserting.
public function getDates() { return array(); }
database / migration / 2013_04_20_125823_create_products_table.php :
public function up() { Schema::create('products', function(Blueprint $table) { $table->increments('id'); $table->string('name'); $table->integer('created_at'); $table->integer('updated_at'); }); }
source share