Display input value type date

4

I have the following input:

<p>Data Saída:</p>
<input type="date" maxlength="10" id="saida" name="saida" value="29/01/2016"/>

It is being displayed as follows:

But I want to display your value and not the dd / mm / yyyy

    
asked by anonymous 18.01.2016 / 18:44

2 answers

1

I solved the problem following certain code:

$data_formatada = DateTime::createFromFormat('d/m/Y', $DtSaida);

<input type="date" maxlength="10" onkeypress="return dateMask(this, event);" id="saida" name="saida" value="<?php echo $data_formatada->format('Y-m-d'); ?>"/>
    
20.01.2016 / 19:20
4

To do this, simply add the contents of the $ DtSaida variable to the YYYY-MM-DD format, see the example below:

<p>Data Saída:</p><input type="date" maxlength="10" id="saida" name="saida" value="2016-01-16"/>

Considering your result you need to remove the print minutes so try something similar to this: echo

<p>Data Saída:</p><input type="date" maxlength="10" onkeypress="return dateMask(this, event);" id="saida" name="saida" value="<?php date_format($DtSaida, 'Y-m-d'); ?>"/>
    
18.01.2016 / 18:51