When I enter day 01 as the date, it returns me the last day of the previous month. What is the reason?
function myFunction() {
var fromdate = new Date(document.getElementById('data_venc').value);
alert(fromdate);
var dd = fromdate.getDate();
var mm = fromdate.getMonth()+1; //January is 0!
var yyyy = fromdate.getFullYear();
alert(dd + " " + mm);
if(dd < 10)
{
dd = '0'+ dd;
alert(dd);
}
if(mm < 10)
{
mm = '0' + mm;
alert(mm);
}
//alert(newdate1);
}
<html>
</head>
</head>
<body>
<div class="recuperar_usuario_senha">
<form>
<h2> Digite a data de vencimento: </h2>
<input type="date" name="data_venc" id="data_venc"/>
<h2>Informações Adicionais</h2>
<textarea cols="45" rows="8" name="textarea" id="textarea" maxlength="225"></textarea>
</br><input onClick="myFunction()" type="image" src="img/gera_boleto.png" value="Confirmar" id="gera_boleto">
</form>
</div>
</body>
</html>