I am looking to add 5 hours & 30 mins to a certain time.
I have,
var d = new Date("Sun Apr 27 2014 16:47:53 GMT+0100");
any help would be much appreciated.
I am looking to add 5 hours & 30 mins to a certain time.
I have,
var d = new Date("Sun Apr 27 2014 16:47:53 GMT+0100");
any help would be much appreciated.
Try this
var d = new Date("Sun Apr 27 2014 16:47:53 GMT+0100");
d.setHours(d.getHours() + 5);
d.setMinutes(d.getMinutes() + 30);
Also there is:
d.setTime(19800000);
The setTime()
method uses milliseconds, but its easy to google seach the number of milliseconds. Though some of the answers above are more useful, this may come in handy for you down the road or for someone else.
Just create a new date from your date object with the extra millis added on
e = new Date(d.getTime() + 1000 * 60 * 30 * 7);
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime