I have this function:
function formatarData(data) {
var d = new Date(data),
mes = '' + (d.getMonth() + 1),
dia = '' + d.getDate(),
ano = d.getFullYear();
if (mes.length < 2) mes = '0' + mes;
if (dia.length < 2) dia = '0' + dia;
return [ano, mes, dia].join('');
}
I can play with it and format the date however I want, but when I enter date 01 and 01, it subtracts 1 year, 1 day and 1 month:
example: step by date 01/01/2018 and returns 20171231.
Would anyone know to tell me what's wrong and how to concert it?