Timeline for How to add 30 minutes to a JavaScript Date object?
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 7, 2020 at 7:40 | history | edited | ashleedawg | CC BY-SA 4.0 |
adjusted formatting to improve readability
|
Dec 29, 2017 at 14:26 | comment | added | Jacobi |
Hi @transformer, I'm not sure I understood your problem, but these are prototype function, you can use in any order you want, ex: var dt = new Date(); then dt.addMinutes(45); dt.addHours(4); or even dt.addMinutes(285); or also dt.addMinutes(45).addHours(4); all will work. If you have a question with some code example, for your problem post it here I'll be happy to help you.
|
|
Dec 28, 2017 at 20:51 | comment | added | Transformer | thanks for the response @Jacobi in my case I dont know the hours before hand. For e.g. I am trying to total all the hours worked in a TableCol across the table rows, to show summary hours. While I can iterate the table; I still dont know how to dynamically, fragment the hours & mins. Here you have it as constants, any chance to make it using a variable function | |
Dec 28, 2017 at 17:05 | comment | added | Jacobi |
Hi @transformer I would do something like this new Date().addHours(4).addMinutes(45); You can call as many as you want, because the methods return "this" which is the current Date Object.
|
|
Dec 28, 2017 at 4:04 | comment | added | Transformer | how can you add 4:45 mins with tihs | |
Mar 1, 2017 at 3:27 | comment | added | RobG |
@TheDembinski—what issues are you expecting? Extending built-ins is generally disliked, but I can't see an issue with Date. It would be nice if each major increment would also optionally set its minor increments (as the set* methods do), so addHours optionally took minutes, seconds and milliseconds so you could do date.addHours(3, 30) to add 3 hours and 30 minutes. addYears would take years, months and days, addMonths would take months and days, addMinutes would take minutes, seconds, milliseconds, etc.
|
|
Nov 5, 2016 at 23:36 | comment | added | Victor Pudeyev | use moment.js instead | |
Oct 24, 2016 at 17:54 | comment | added | The Dembinski | Can anyone see any issue with this approach? | |
Oct 13, 2016 at 13:44 | history | edited | Jacobi | CC BY-SA 3.0 |
only changed the example
|
Mar 19, 2014 at 20:05 | history | edited | Jacobi | CC BY-SA 3.0 |
added 454 characters in body
|
Mar 19, 2014 at 19:14 | history | answered | Jacobi | CC BY-SA 3.0 |