1 Reply Latest reply on Jul 10, 2006 4:57 PM by blemmo

    Using Date Object to Display 2 Days Ago

    BillG-Seattle Level 1
      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
        • 1. Re: Using Date Object to Display 2 Days Ago
          blemmo Level 1
          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.