I'm trying, with javascript, to automatically calculate a date. I have a date as a text-variable, wich I have parsed into three variables yy, mm, dd. When I try to recalculate a future date I get a very strange, and very wrong result.
My code looks like this:
Code: Select all
var yy='2002', mm='08', dd='28';
// Create date
myDa = new Date();
// Set future date.
myDa.setYear(yy.valueOf());
myDa.setMonth(mm.valueOf()+1);
myDa.setDate(dd.valueOf());
// Debug
alert(myDa.getYear().asString()+'-'+myDa.getYear().asString()+'-'+myDa.getDate());