Timeline for How to add 30 minutes to a JavaScript Date object?
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 6, 2022 at 7:00 | comment | added | Vineesh TP | returning the date - new Date(newDateObj.setTime(oldDateObj.getTime() + (30 * 60 * 1000))); | |
May 10, 2021 at 23:37 | comment | added | DharmaTurtle |
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))
|
|
S May 22, 2019 at 12:52 | history | suggested | hashed_name | CC BY-SA 4.0 |
Update code snippet
|
May 22, 2019 at 12:04 | review | Suggested edits | |||
S May 22, 2019 at 12:52 | |||||
Jun 18, 2017 at 12:44 | comment | added | RobG |
var in30Mins = new Date(+new Date() + 1.8e6) is a one–liner, but not sure it's any better than a two–liner. ;-)
|
|
Dec 24, 2011 at 0:33 | comment | added | Alan H. |
Note that setTime returns a numeric millisecond timestamp, not a date object. (Don’t think you can do a one-liner.)
|
|
Jul 29, 2009 at 3:38 | history | answered | chaos | CC BY-SA 2.5 |