DB Attribute with TIMESTAMP - Not possible to save timestamp

Hey guys,

I have an attribute called "date" in my DB with the datatype "TIMESTAMP"

When executing the following code in my model the following data is saved in the DB:


0000-00-00 00:00:00

(instead of the timestamp…)

Model Code:




	protected function beforeValidate()

	{		

		$this->date = time(); 


		return parent::beforeValidate();

	}



Your DBMS doesn’t accept an integer value for a timestamp column. It needs to be converted to a properly formatted string:




$this->date = date('Y-m-d H:i:s');



yep… THX that makes sense

Thanks…help me too… :lol:

Don’t Work for me I use this code




$model->fechora=date('Y-m-j h:i');



And show this error

CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: