TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], ], ], ]; } public function afterFind() { parent::afterFind(); isset($this->created_at) && $this->created_at = date('Y-m-d H:i:s', $this->created_at); isset($this->updated_at) && $this->updated_at = date('Y-m-d H:i:s', $this->updated_at); } public function getUserPatient() { return $this->hasMany(UserPatient::className(),['id'=>'user_patient_id']); } }