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.

5
  • 162
    @Jamie: You don't need two Date objects. var d = new Date(); d.setMinutes(d.getMinutes() + 30); Commented Jul 29, 2009 at 21:28
  • 19
    @Grant: I assumed d2 = "I'd like to get a Date object" and d1 = "to another Date object"
    – Jamie
    Commented Jul 30, 2009 at 17:53
  • 7
    @CKeene, setMinutes & getMinutes are part of plain old Javascript (though datejs does provide a whole bunch of other stuff).
    – s29
    Commented Feb 15, 2012 at 5:19
  • 7
    FYI- this can break across Daylight Saving Time boundaries. JSFiddle demos: "spring forward" / "fall back" (Thanks @Spig for this)
    – Kip
    Commented Sep 17, 2014 at 17:18
  • 3
    @trevorgrayson If a parameter you specify is outside of the expected range, setMinutes() attempts to update the date information accordingly. For example, if you use 100, the hours will be incremented by 1 and 40 will be used for minutes. Commented Dec 30, 2014 at 6:34