public function actionReturn($id) { /** * @var $model Borrow */ $model = Borrow::model()->findByPk($id); $model->return_date = date('Y-m-d'); $model->save(); if (strtotime($model->return_date) > strtotime($model->due_date)) { echo 'bad'; } else { echo 'good'; } }