Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q469 How do I get the dates of next seven weeks in advance

You are here: irt.org | FAQ | JavaScript | Date | Q469 [ previous next ]

Try:

<script language="JavaScript"><!--
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function add_days(adate,days) {
    return new Date(adate.getTime() + (days * 86400000));
}

function format_date(adate) {
    return adate.getDate() + '/' + (adate.getMonth()+1) + '/' + y2k(adate.getYear());
}

function show_dates(adate) {
    var then = add_days(now,7);    // move date forward 7 days
    var begin = format_date(now);  // format date
    var end   = format_date(then); // format date
    document.write(begin + ' - ' + end + '<BR>');
}

var now = new Date(2000,10-1,27); // set date to 27th October 2000

for (var i=0; i<7; i++) {
    // do this loop 7 times
    show_dates(now);       // show dates for beginning and end of week
    now = add_days(now,7); // move date forward a week
}
//--></script>

Feedback on 'Q469 How do I get the dates of next seven weeks in advance'

©2018 Martin Webb