i need a date in "YYYY-mm-dd" format from some days past. i write this function:
function getDifDate(d, numd) {
d = stringToDate(d);
d.setDate(d.getDate() - numd);
return d;
}
then in another part of the program i write:
var tod = new Date();
switch(selPer.value) {
case 1:
x= getDifDate(tod, 2);
break;
case 2:
x= getDifDate(tod, 15);
break;
default:
//default code block
}
console.log("Data1: "+ x);
but the x value, for example if i launch today my script return ever "25"
What is wrong?
Thanks in advance