I need to show the current date in a date type input instead of "dd / mm / yyyy".
I need to show the current date in a date type input instead of "dd / mm / yyyy".
To do so, you should use JavaScript.
You can use the object Date
, I recommend you read a bit about it to give it a more specific use
n = new Date();
//Año
y = n.getFullYear();
//Mes
m = n.getMonth() + 1;
//Día
d = n.getDate();
//Lo ordenas a gusto.
document.getElementById("date").innerHTML = d + "/" + m + "/" + y;
<h1 id="date"></h1>
You could try something like the following:
window.onload = function(){
var fecha = new Date(); //Fecha actual
var mes = fecha.getMonth()+1; //obteniendo mes
var dia = fecha.getDate(); //obteniendo dia
var ano = fecha.getFullYear(); //obteniendo año
if(dia<10)
dia='0'+dia; //agrega cero si el menor de 10
if(mes<10)
mes='0'+mes //agrega cero si el menor de 10
document.getElementById('fechaActual').value=ano+"-"+mes+"-"+dia;
}
<input type="date" id="fechaActual" value="" >