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.

4
  • 4
    Note that setTime returns a numeric millisecond timestamp, not a date object. (Don’t think you can do a one-liner.)
    – Alan H.
    Commented Dec 24, 2011 at 0:33
  • 15
    var in30Mins = new Date(+new Date() + 1.8e6) is a one–liner, but not sure it's any better than a two–liner. ;-)
    – RobG
    Commented Jun 18, 2017 at 12:44
  • 2
    In case the winky face was too subtle, using +new Date() is not generally recommended: stackoverflow.com/a/221565 However, using the info from that link, I believe the following is fine: new Date(Date.now() + (30 * 60 * 1000)) Commented May 10, 2021 at 23:37
  • returning the date - new Date(newDateObj.setTime(oldDateObj.getTime() + (30 * 60 * 1000)));
    – Vineesh TP
    Commented Jul 6, 2022 at 7:00