This content has been marked as final. Show 4 replies
The date is in us format i.e. month/date/year. If you take 3 from 2 thats -1, you would need to write some sort of loop if you want it to jump back a month say from the 2nd july to the 30th june if you take 3 days off.
What I am thinking now is this: create a test variable like this:
public var test:Number = (new Date().day -3);
and then check if the var is less than 1, meaning that I will have to get the previous month and then subtract from the prev. months days inside the CreationComplete handler:
if (test < 1)
//day is less than one, find the number of days in the previous month and do the following
//1: add 1 to the test var
//2. do this: NumberOfDaysOfPrevMonth - test
//day is 1 or bigger, just subtract from the current month
beginDate = (new Date().getMonth()) + "/" + (new Date().getDate() - 3) + "/" + (new Date().fullYear.toString());
What is the syntax for finding the number of days of the previous month? (steps 1 and 2 in the first part of the if stmt). thanks
The month problem you're having is because Date's months are zero-based, i.e. 0 is January, 1 is February, etc.
The best way to do this is to use the getTime() function.
date3DaysBack = new Date(currentDate.getTime() - 3 * 24*60*60*1000);