(Last Updated On: March 26, 2010)

I needed to work out a date range according to the date 3weeks away from the current date.
After a bit of thinking, I found that it’s actually quite easy to achieve.
[code lang=”actionscript”]
var theDate:Date = new Date();
dateDay = theDate.getDate();
dateMonth = theDate.getMonth();
dateYear = theDate.getFullYear();

var theDate2:Date = new Date(dateYear,dateMonth,dateDay);
theDate2.setDate(theDate2.getDate() + 21);
dateDay2 = theDate2.getDate();
dateMonth2 = theDate2.getMonth();
dateYear2 = theDate2.getFullYear();
The above code gets the current date and adds 21days/3weeks to it.
Remember that if you use getMonth to output the final month number, you will want to add 1 to it as it starts at 0;
[code lang=”actionscript”]dateMonth2 = theDate2.getMonth()+1;[/code]
So you would do it like this:
[code lang=”actionscript”]theDate2.getDate() +”/”+ (theDate2.getMonth()+1) +”/”+ theDate2.getFullYear();[/code]

Leave a Reply

Your email address will not be published.

%d bloggers like this: