Good morning to everyone.
I am trying to do a Select by filtering only by date in a DB with MySQL, in timestamp column format, where data with this format is inserted ('Y-m-d H: i: s').
The dates I receive from this form:
Filtrar Registros por dia :<br>
<form action='<?php $_SERVER['PHP_SELF']?>' method='POST'>
<p>23 Noviembre <input type='radio' name='dia' value='2016-11-23'/></p>
<p>24 Noviembre <input type='radio' name='dia'value='2016-11-24'/></p>
<p><input type=submit name='filtrar' VALUE=Filtrar></p>
</form>
Filtrar Registros por hora:<br>
<form action='<?php $_SERVER['PHP_SELF']?>' method='POST'>
<p>16:00 H<input type='radio' name='hora' value='16:00:00'/></p>
<p>17:00 H<input type='radio' name='hora' value='17:00:00'/></p>
<p>18:00 H<input type='radio' name='hora' value='18:00:00'/></p>
<p><input type=submit name='filtrar1' VALUE=Filtrar></p>
</form>
I pass the data to PHP in this way to do the Select:
if ( !isset($_POST['filtrar']) || !isset($_POST['dia']) ){}else{
$date =$_POST['dia'];
$now = new DateTime($date);
$hoy=$now->format('Y-m-d');
echo "<h1>".$hoy."</h1>";
$registros=mysqli_query($conexion,"SELECT * FROM 'nom_tab' WHERE 'Fecha' = '$hoy'")
or die('Problemas al buscar'. mysqli_error());
}
$row_cnt = $registros->num_rows;
If the query works I show the data in a table.
My question is:
What or Comó, I can do to filter only by ('Y-m-d')?
Since MySQL expects it to happen ('Y-m-d H: i: s').
Thank you in advance for everything. Greetings.