public function beforeValidate() { if ($this->getIsNewRecord()) { $this->created_at = time(); } $this->updated_at = time(); return parent::beforeValidate(); }