JSFiddle - React, Tailwind, and code Playground
by Fabian Allel
JavaScript
function restarDiasFecha(dias) {
var todayDate = new Date(),
weekDate = new Date();
weekDate.setTime(todayDate.getTime() - (dias * 24 * 3600000));
return weekDate;
}
function devuelveStringFecha(fecha) {
return fecha.getFullYear() + '-' + ("0" + (fecha.getMonth() + 1)).slice(-2) + '-' + ("0" + (fecha.getDate() + 1)).slice(-2);
}
console.log(devuelveStringFecha(restarDiasFecha(50)));