Feature/eloquent unix timestamps #769

wants to merge 4 commits into


None yet

In regards to #705

Andrew Ellis and others added some commits May 23, 2012
Andrew Ellis implemented the ability to use unix timestamps on models 462f9aa
@JesseObrien JesseObrien Merge branch 'master' of https://github.com/laravel/laravel into feat…
@JesseObrien JesseObrien Added unix_timestamps() method to schema builder.
On recommendation from @taylorotwell, unix_timestamps adds a way to
specify a timestamp field should be created as a unix_timestamp field
instead of a date-time field.
@JesseObrien JesseObrien Update Schema docs to reflect unix_timestamps() method. 856b793
afarazit commented Jul 4, 2012








ellisio commented Aug 10, 2012

Is this ever going to get pulled in? Starting to get annoying having to recreate all these files for new projects :(

ellisio commented Aug 10, 2012

Looks like a timestamp() function was added to Eloquent. Did not notice that. Nice!


Hi @awellis13 I will nag @taylorotwell about this one. It seems greatly desired and Eloquent is his baby.

Thanks man!


Yeah I've had to hack together a base model to use in all of our projects now, it would be nice to have this pulled. @awellis13 did a nice job on it.


Taylor doesn't like non-expressive parameters like the one you added to the date() function, though.

I'd suggest you actually leave that in, but also add another function, maybe unix_date(), that only accepts one parameter and then calls date() with that parameter (or maybe doesn't rely on it, it's simple enough to re-implement).


Since $column is an instance of Laravel\Fluent, would it be better to use it as

Schema::create('users', function ($table)
@crynobone crynobone commented on the diff Aug 11, 2012
@@ -185,12 +185,36 @@ public function fill_raw(array $attributes)
public static function accessible($attributes = null)
- if (is_null($attributes)) return static::$accessible;
+ if (is_null($attributes)) {
crynobone Aug 11, 2012

most Laravel code use own line for braces*, and condition without semicolon is accepted by in Laravel (since @taylorotwell use it mostly)

  • edited
franzliedke Aug 11, 2012

Semicolon? Braces. (Just trying to avoid confusion :) ).


@crynobone Good idea. That would set the field unix to true on the Fluent object, right?


should work the same as nullable, on mobile right now, it either true or isset


This has been addressed in Eloquent 3 / Laravel 4.


Does anybody know how has this been addressed in Laravel 4? I can't find any reference to unix timestamps in the documentation or source. I don't really want to have to 1) define two integers on every new table, where timestamps() was sufficient before and 2) set freshTimestamp() on every model. Is there no implementation similar to this pull request available?


In the same boat as @BlueHayes. How was this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment