I have two fields, dateCreated, dateChanged. They are both timestamp fields. I want to use the TimeStampBehavior in the controller to fill these fields automatically. I’ve placed this code in the controller:
public function behaviors(){
return array(
'CTimestampBehavior' => array(
'class' => 'zii.behaviors.CTimestampBehavior',
'createAttribute' => 'create_time_attribute',
'updateAttribute' => 'update_time_attribute',
)
);
}
I’ve not been successful in having the two fields filled automatically. Any help will be appreciated.
I would like to ask about this behavior. I set the timezone in the index.php file in my yii project. Unfortunately this TimestampBehavior does not take care this timezone setting. How can i set the timezone in the behavior ?
if you check the source code you will see that this behavior sets the value of the fields to CDbExpression(‘NOW()’)… so it’s the database (not the PHP script) that sets the date…