/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Registro(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Registro'])) { $model->attributes = $_POST['Registro']; if ($model->save()) { $tiempo = $model->tiempo; $entrada = $model->entrada; ////funcion sumar function sumarMinutosFecha($FechaStr, $MinASumar) { $FechaStr = str_replace("-", " ", $FechaStr); $FechaStr = str_replace(":", " ", $FechaStr); $FechaOrigen = explode(" ", $FechaStr); $Dia = $FechaOrigen[2]; $Mes = $FechaOrigen[1]; $Ano = $FechaOrigen[0]; $Horas = $FechaOrigen[3]; $Minutos = $FechaOrigen[4]; $Segundos = $FechaOrigen[5]; // Sumo los minutos $Minutos = (int) $Minutos + (int) $MinASumar; // Asigno la fecha modificada a una nueva variable $FechaNueva = date("Y-m-d H:i:s", mktime($Horas, $Minutos, $Segundos, $Mes, $Dia, $Ano)); return $FechaNueva; } $salida = sumarMinutosFecha($entrada, $tiempo); $id = $model->id; $link = mysqli_connect("localhost", "root", "root", "bolera"); $sql = "UPDATE registro SET salida='{$salida}' WHERE id='{$id}'"; mysqli_query($link, $sql); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); $this->renderPartial('/site/buscarsalida'); }