Show datetime of MySQL in input datetime-local html

0

I have a problem bringing a date and time from a MySQL table that I saved previously through an HTML and PHP form. Here my code:

<!doctype html>
<?php

include('libreria/motor.php');
require ('connection.php');
require ('libreria/verificar-usuario.php');
require ('libreria/solo-admin.php');

$v1 =$_GET['id'];
if (isset($v1)) {
    $v2 = $v1;
    $query="select * from tareas where ID='$v2'";
    $result=mysql_query($query);
    $fila=mysql_fetch_array($result);
}else{
    header("Location: tareas.php");
}

$hora=strtotime($fila['TIEMPOASIG']);
echo $fila['TIEMPOASIG'];
//imprime 2018-03-30 18:00:00
echo $hora;
//imrpime 1522425600
$horaformateada=date("d/m/Y G:i", $hora);
echo $horaformateada;
//imprime 30/03/2018 18:00

$viajebuque=$fila['NROVIAJE'];
$queryx="SELECT BUQUE as buqueviaje FROM viajes WHERE NROVIAJE='$viajebuque'";
$resultx=mysql_query($queryx);
$filax=mysql_fetch_assoc($resultx);
$buqueviaje=$filax["buqueviaje"];

$result = mysql_query("SELECT NROVIAJE, BUQUE FROM viajes ORDER BY NROVIAJE ASC");
$opcion=' ';
while($row=mysql_fetch_assoc($result)){
    $opcion .= '<option value = "'.$row['NROVIAJE'].'">'.$row['NROVIAJE'].' - '.$row['BUQUE'].'</option>';
}
$resultch = mysql_query("SELECT nombre FROM usuarios ORDER BY nombre ASC");
$opcionch=' ';
while($row=mysql_fetch_assoc($resultch)){
    $opcionch .= '<option value = "'.$row['nombre'].'">'.$row['nombre'].'</option>';
}

?>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Modificar Tarea</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>
<h1>Modificar Tarea</h1>
<div class="form-group">
<form id="form1" name="form1" method="post">
<label for="NROVIAJE">Número de Viaje:</label>
<select name="NROVIAJE" required id="NROVIAJE">
    <option value="<?php echo $fila['NROVIAJE']; ?>"> <?php echo $fila['NROVIAJE']; ?> -  <?php echo $buqueviaje; ?></option>
    <?php echo $opcion; ?>
  </select><br>
<label for="TAREA">Tarea</label>
<input name="TAREA" type="text" required id="TAREA"  value="<?php echo $fila['TAREA']; ?>"><br>
<label for="DETALLESTAREA">Detalles de Tarea</label>
<textarea name="DETALLESTAREA" required id="DETALLESTAREA"  ><?php echo $fila['DETALLESTAREA']; ?></textarea><br>
<label for="TIEMPOASIG">Tiempo asignado para finalización</label>
<input name="TIEMPOASIG" type="datetime-local" required= id="TIEMPOASIG" value="<?php echo $horaformateada; ?>"><br>

<!-- no muestra ninguna hora -->

<label for="RESPONSABLE">Tarea asignada a:</label>
<select name="RESPONSABLE" required id="RESPONSABLE"  >
    <option value="<?php echo $fila['RESPONSABLE']; ?>"> <?php echo $fila['RESPONSABLE']; ?> </option>
    <?php echo $opcionch; ?>
  </select><br>
<input name="Enviar" id="Enviar" value="Enviar" type="submit" class="btn btn-default">
</form>
</div>
</body>
</html>

In the TIEMPOASIG input I would like to show the date and time that I am bringing from the MySQL database, so that the user can edit it and save a new date and time in the database if he wishes, but I can not find it the way.

Thank you very much in advance.

    
asked by eduardoimm 18.03.2018 в 06:28
source

0 answers