How can I save the time on my BD?

0

This is my form which I have a variable time that is synchronized with the PC time what I want to be able to record the time on my BD the problem is that it is not saving.

formato.php

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html"; charset="utf-8">
    <title>Formato De Servicio</title>
</head>
<body>
    <h1>Regulacion</h1>
    <form  action="guardarFormato.php" method="post">

        <?php
        date_default_timezone_set("America/BOGOTA" ) ;
        $hora = date('h:i a',time() - 3600*date('I'));
        ?>

    <label>Hora:<input type=text name="hora" <?php echo "value='$hora'";?> disabled></label>
    </form> 
</body>
</html>

saveFormat.php

<?php
    // Abrimos la conexion a la base de datos   
    $conexion = mysqli_connect("localhost","root","admin123","database");

    // Recibimos por POST los datos procedentes del formulario   
    $hora = $_POST["hora"];

    $guardar = "INSERT INTO servicio (hora) VALUES ('".$hora."') ";
    $resultado = mysqli_query($conexion,$guardar);
    if (!$resultado) {
        echo '<script>
                alert("la hora fue registrada");
             </script>';

    }else{
            header("location:mostrarServicios.php");
          } 
   ?>
    
asked by Cristian Antonio Trujillo Gris 17.05.2018 в 14:37
source

0 answers