/** * Creates a new PeriodoInscricaoMonitoria model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new PeriodoInscricaoMonitoria(); if ($model->load(Yii::$app->request->post())) { if (strtotime($model->dataInicio) >= time() && strtotime($model->dataInicio) < strtotime($model->dataFim) && strtotime($model->dataFim) > time() && strtotime($model->dataInicio) != strtotime($model->dataFim) && ($model->ano = date('Y', strtotime($model->dataInicio)))) { $model->dataInicio = Yii::$app->formatter->asDate($model->dataInicio, 'php:Y-m-d'); $model->dataFim = Yii::$app->formatter->asDate($model->dataFim, 'php:Y-m-d'); //$model->ano = date('Y', strtotime($model->dataInicio)); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { $model->delete(); return $this->render('aviso'); } } else { return $this->render('create', ['model' => $model]); } }