all groups > flash actionscript > july 2006 >
You're in the

flash actionscript

group:

Using Date Object to Display 2 Days Ago


Using Date Object to Display 2 Days Ago BillG-Chicago
7/10/2006 10:57:22 PM
flash actionscript: There's probably an elegant solution to this, but... can anyone provide
pointers on the best way to display a date that's for example, 2 days ago...or
exactly one month from today's date? It seems like this should be relatively
straightforward, but I'm concerned with when new months/years intervene...and
making sure all the possibilities are covered. Thoughts would be greatly
appreciated! - BillG
Re: Using Date Object to Display 2 Days Ago blemmo
7/10/2006 11:57:36 PM
You can construct a Date object from the current date, get the milliseconds of
it (Date.UTC I think), then add or substract the milliseconds of the timespan
you need (1 day = 24*60*60*1000 ms), and get another Date object from the
resulting value. This should get you the right date, taking the different month
length and even leap years into account.

hth,
blemmo
AddThis Social Bookmark Button