How can I add [# of days] to a date?


edit::  nevermind, found answer.  i'm using 2.0

answer: new date(year, month, date+#)  # # of days add.

helpful link: http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/  (as 2.0 & 3.0)

 

original question:

 

the title horrible, couldn't think of how word it.

 

anyway, want know how can take date, add few days it, display resulting date.

 

for example, today's date 8/20/2010.  want able add 10 days , display result in label or other output.

 

the label read 8/30/2010.  if wanted add 15 days today's date, label read 9/4/2010.

 

any appreciated, thanks!

another way of adding values date object set constants, , make life easier if date math frequently, or adding date unknown until runtime (i.e., not neccessarily today's date).

 

 

            private var todaydate:date = new date();

 

            //one day, in milliseconds:
            private const oneday:number = 1000 * 60 * 60 * 24;

 

            private function adddaystothedate():void {
                //the number of days wish add:
                var daystoadd:number = oneday * 10;
                //add days today's date:
                var answer:date = new date(todaydate.time + daystoadd);
                alert.show(answer.todatestring());
            }



More discussions in Flex (Read Only)


adobe

Comments

Popular posts from this blog

How to decompile jsxbin to jsx

Gavik Photoslide GK2: Not able to upload photos - Joomla! Forum - community, help and support

Phoca Guestbook logger registret bruger af - Joomla! Forum - community, help and support