I am trying to retrieve a date in the "YYYY-mm-dd" format from some days ago using the following function:
function getDifDate(d, numd) {
d = stringToDate(d);
d.setDate(d.getDate() - numd);
return d;
}
Subsequently in another section of the program, I have written:
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);
The issue I am experiencing is that regardless of when I run the script, the value for x always returns as "25". What could be causing this inconsistency?
Any insights would be greatly appreciated.