where are created_at and updated_at values in User table set ?

I created Yii Advance Application template. Everything works great.

As I went through the code to understand Yii 2.0, I could not find where created_at and updated_at values were set ?

Any ideas ?

public function beforeSave($insert)     {         

     if (parent::beforeSave($insert)) {             

         if ($this->isNewRecord) {                 

        // if it is new record save the current timestamp as created time                 

         $this->created_at = time();            


// if it is new or update record save that timestamp as updated time            

 $this->updated_at = time();            

 return true;         

}         return false;   


use this in All models .

Aren’t those added with http://www.yiiframework.com/doc-2.0/yii-behaviors-timestampbehavior.html ?

Like Bizley said - I would do it with Timestamp Behavior…

And in default user model it is also done with Timestamp Behavior.

Of course you could also do what ilaiya wrote…

But then I would do this in a self created BaseModel and let all other models inherit from that one… then you don’t have to write beforeSave in every controller.


it makes sense to me now. Thanks Bizley