Date, next month.
Posted: Sun Sep 01, 2002 6:07 am
Hi there.
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:
My reservation an minor error somewhere, I wrote the function from my memory. Acturally I get the following date '2008-10-23', wich is very strange. Anyone who have a sugestion?
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());