HTML / JS / PHP: Transform date entry into dd / mm / yyyy

1

Good morning. In my mysql database the dates are saved as dd / mm / yyyy, but the html "date" input only returns dates in the format yyyy-mm-dd, so I can not filter the dates of the database, which was my goal. I was using a very simple code, like this one below:

<input type="date"  name="parametro"> 
<input type="submit" value="Filtrar Data">

How do I return the date in the same format as the bank? In the case of using plugins, how to use them?

    
asked by anonymous 06.04.2018 / 12:56

2 answers

0

Based on the answers I got I was able to find a solution: As I needed to filter by date in dd / mm / yyyy format, I used the following code in html and php:

HTML :

<input  type="date" placeholder= "dd/mm/aaaa" name="parametro" > 
<input type="submit" value="Filtrar Data"> 

PHP :

 $parametro = filter_input(INPUT_GET, "parametro");
 $data = date('d/m/Y', strtotime($parametro));
    
06.04.2018 / 16:01
1

With PHP is simple to solve, just convert your base to the input format

$dataBanco = "06/04/2018";
$data = date('Y-m-d', strtotime($dataBanco));
echo $data;
    
06.04.2018 / 14:57