Timeline for How to add 30 minutes to a JavaScript Date object?
Current License: CC BY-SA 3.0
47 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 24, 2022 at 5:31 | answer | added | Sahil Jaidka | timeline score: 1 | |
Nov 12, 2022 at 13:43 | answer | added | aljgom | timeline score: 7 | |
Jul 11, 2022 at 16:06 | history | rollback | Liam |
Rollback to Revision 5
|
|
Jul 11, 2022 at 16:05 | history | edited | Liam | CC BY-SA 4.0 |
edited title
|
Dec 11, 2021 at 18:12 | answer | added | C B | timeline score: 25 | |
Sep 28, 2021 at 8:42 | answer | added | phentnil | timeline score: 5 | |
Jun 13, 2021 at 6:47 | answer | added | Mansour Alnasser | timeline score: 49 | |
May 26, 2021 at 7:26 | answer | added | ISK | timeline score: 5 | |
May 26, 2021 at 7:15 | answer | added | ISK | timeline score: 1 | |
Apr 30, 2021 at 20:08 | answer | added | DolDurma | timeline score: 1 | |
Apr 2, 2021 at 13:28 | answer | added | Duncan Lukkenaer | timeline score: 31 | |
Nov 9, 2020 at 14:07 | answer | added | Cedrick Campoto | timeline score: 9 | |
Sep 4, 2020 at 12:12 | answer | added | German Gracia | timeline score: 4 | |
Jul 7, 2020 at 21:23 | answer | added | gildniy | timeline score: 5 | |
Apr 20, 2020 at 0:34 | answer | added | Abdulrahman Fawzy | timeline score: 12 | |
Apr 7, 2020 at 12:36 | answer | added | Adnane Ar | timeline score: 5 | |
Mar 13, 2020 at 9:14 | answer | added | Jason Mullings | timeline score: 7 | |
Feb 6, 2020 at 11:02 | answer | added | rayalois22 | timeline score: 6 | |
Nov 20, 2017 at 16:18 | answer | added | tsacodes | timeline score: 20 | |
May 7, 2017 at 15:06 | answer | added | unsynchronized | timeline score: 6 | |
Apr 13, 2017 at 11:47 | answer | added | Zameer Ansari | timeline score: 7 | |
Jun 16, 2016 at 21:18 | answer | added | Ouroborus | timeline score: 4 | |
May 25, 2016 at 13:15 | comment | added | Alex | Consider marking an answer as accepted | |
Oct 15, 2015 at 17:33 | comment | added | eMarine | Could be possible that you guys verify the correct answer? | |
Feb 19, 2015 at 16:13 | answer | added | Blaskovicz | timeline score: 3 | |
Jan 29, 2015 at 22:58 | history | edited | Eric Leschinski | CC BY-SA 3.0 |
added 14 characters in body
|
Dec 29, 2014 at 10:47 | history | edited | halfer | CC BY-SA 3.0 |
Fix case
|
Nov 6, 2014 at 16:00 | comment | added | Kip | @MorganCheng: Could you accept my answer if you think it's the best? This is by far my most popular answer but it is not the accepted answer. :) | |
Sep 17, 2014 at 17:06 | comment | added | Kip | @Spig: FWIW, my top-voted answer has always worked fine in this case. :) It uses getTime() and setTime(), so it is based on unix timestamp (which doesn't care about DST) | |
Sep 17, 2014 at 17:05 | comment | added | Kip |
@Spig: interesting, tried it on Firefox and it worked. I think it falls into a grey area in the specification of how getMinutes() should work. 01:89 would become 02:29 , which doesn't exist on the day you "spring forward". Chrome decides that should be 01:29 , FF decides on 03:29 . On the night when you "fall back", both browsers skip the "fall back" hour and jump ahead by 90 minutes, to 02:29 . Here are some JSFiddle demos: "spring forward" / "fall back"
|
|
Sep 17, 2014 at 15:23 | comment | added | Spig |
@Kip: On Chrome if I add a console.log(d, d.getTime(), '---', f, f.getTime()) to my original string, the output is Sun Mar 09 2014 01:29:00 GMT-0500 (EST) 1394346540000 " --- " Sun Mar 09 2014 01:59:00 GMT-0500 (EST) 1394348340000 . EST does not roll over to EDT. f should be smaller than d since I added 30 minutes to d , not the other way around.
|
|
Sep 16, 2014 at 14:24 | comment | added | Kip |
@Spig: 30 minutes after 1:59 AM on DST boundary is 1:29AM. There is no error. If you print f and d , you'll see one says "GMT-0500" the other says "GMT-0400" (or whatever your time zone is). Also, if you call .getTime() on both f and d , you'll see that f is larger than d (i.e. later).
|
|
Sep 12, 2014 at 15:07 | comment | added | Spig |
All answers below that use a variation of date.setMinutes(date.getMinutes() + ...) will fail crossing over Daylight Saving boundaries. For example (assuming '2014-03-09' is a Daylight Saving boundary): var d = new Date('2014-03-09 01:59:00'), f = new Date(d.getTime()); d.setMinutes(d.getMinutes() + 30); d is now 30 minutes earlier, not later, than f .
|
|
Mar 19, 2014 at 19:14 | answer | added | Jacobi | timeline score: 63 | |
Oct 15, 2013 at 12:54 | answer | added | Jonathan | timeline score: 13 | |
Aug 29, 2011 at 17:36 | history | edited | Kip | CC BY-SA 3.0 |
improved language, and removed unnecessary examples
|
May 21, 2011 at 22:34 | history | protected | Jeff Atwood | ||
May 21, 2011 at 15:12 | comment | added | David d C e Freitas | See also stackoverflow.com/questions/674721/… | |
Jun 14, 2010 at 13:58 | answer | added | Teo Graca | timeline score: 139 | |
Aug 14, 2009 at 15:45 | answer | added | Jim Davis | timeline score: 2 | |
Jul 31, 2009 at 20:36 | answer | added | Kip | timeline score: 1343 | |
Jul 29, 2009 at 3:44 | comment | added | Christian | I built a little calendar popup script in js, its on Github, maybe look through the code to see how the date object is interected with. Also, check Javascript Kit as its an awesome js reference, especially for the date object. | |
Jul 29, 2009 at 3:43 | history | edited | chaos | CC BY-SA 2.5 |
edited body; edited tags; added 6 characters in body; edited tags
|
Jul 29, 2009 at 3:40 | answer | added | Jamie | timeline score: 366 | |
Jul 29, 2009 at 3:39 | answer | added | Tyler Carter | timeline score: 68 | |
Jul 29, 2009 at 3:38 | answer | added | chaos | timeline score: 213 | |
Jul 29, 2009 at 3:34 | history | asked | Morgan Cheng | CC BY-SA 2.5 |