Brian Genisio <> writes:
> Here is a quick way to do it... I am sure there are others...
>
> var msInDay = 1000 * 60 * 60 * 24;
Bad idea. The date object has much safer ways to add one day, that
won't get confuzed by changes to and from daylight saving time.
> // Get today's date
> var today = new Date();
>
> // Set the date to saturday 0 = Sunday to 6 = Saturday
> var dayOffset = (6 - today.getDay()) * msInDay;
Just use
var dayOffset = 6 - today.getDay();
and use it on the date, not the milliseconds.
Shorter version:
var date = new Date();
date.setDate(date.getDate()+6-date.getDay()); // first coming Saturday.
for(var i=0;i<10;i++) {
document.write(date.toString() + "<br>");
date.setDate(date.getDate()+7);
}
/L
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'