BWSnippet

Yii easy createdOn updatedOn handling

Yii easy createdOn updatedOn handling

An easy way to handle createdOn - modifiedOn / updatedOn dates for models. Just add "beforeSave" to model.

public function beforeSave()
     {
         if ($this->isNewRecord)
             $this->createdOn = new CDbExpression('NOW()');
         else
             $this->modifiedOn = new CDbExpression('NOW()');
    
         return parent::beforeSave();
     }



Tags

Yii easy createdOn updatedOn handling