Entry
How to add minutes to a date and return as a GMT string?
May 10th, 2001 10:01
jsWalter, Chris Durkin,
wt 5/10/01
I have a collection of methods that extend the Date Object.
One of them solves this problem.
ww.torres.ws/javascript
Walter
=============================
function minutesFromNow (nn, gmt) {
// desc: adds minutes to the current date and returns as string
// nn: integer, the number of minutes to add
// gmt: GMT flag - set it to force "GMT"
var dt1 = new Date();
var dt2 = new Date(dt1.valueOf() + (nn * 60000));
var gmtstr = (Date.toUTCString) ? dt2.toUTCString() : dt2.toGMTString
();
return (gmt) ? gmtstr.slice(0, -4) + " GMT": gmtstr;
}
example of use:
var dt = new Date();
document.write("Today's date: " + dt.toGMTString() + "<br>");
document.write("1 hour from now: " + minutesFromNow(60) + "<br>");
// force GMT instead of UTC
document.write("1 hour from now GMT: " + minutesFromNow(60,1));