Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 8
    The .addDays() method does not work for dates that cross daylight saving time boundaries. Commented Apr 29, 2013 at 0:02
  • 2
    This is one of the better answers here because you (correctly) use the number of millis since the epoc to represent dates/times, and add amounts of millis for adjustments... Why then did you not keep this up for "addMonths"!? And why no add year? Did you get bored? Commented Apr 23, 2015 at 13:03
  • Other than months, time periods can be represented by static numbers. But months can be four different lengths. Also, any time period length from Days and higher may have variable length at DST, so you can't use time-based addition anymore without another level of complexity. I added the addYears(), and I fixed addMonths(). Commented Apr 16, 2016 at 19:55