Add DateTime support to database binding layer.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell
2012-04-10 15:03:42 -05:00
parent 7d5b6b3748
commit 94b8582865
7 changed files with 32 additions and 15 deletions

View File

@@ -193,7 +193,7 @@ abstract class Model {
{
$model = new static(array(), true);
if (static::$timestamps) $attributes['updated_at'] = $model->get_timestamp();
if (static::$timestamps) $attributes['updated_at'] = new \DateTime;
return $model->query()->where($model->key(), '=', $id)->update($attributes);
}
@@ -405,21 +405,11 @@ abstract class Model {
*/
protected function timestamp()
{
$this->updated_at = static::get_timestamp();
$this->updated_at = new \DateTime;
if ( ! $this->exists) $this->created_at = $this->updated_at;
}
/**
* Get the current timestamp in its storable form.
*
* @return mixed
*/
public static function get_timestamp()
{
return date('Y-m-d H:i:s');
}
/**
* Get a new fluent query builder instance for the model.
*