Forum Moderators: open
This is not going to be straightforward! To get todays day (of the month), you would use the Date() method:
var today=new Date();
dayOfMonth = today.getDate();
monthOfYear = today.getMonth();
dayOfMonth = dayOfMonth+21;
You will need to work out the logic of this by taking what month of the year it is, and from there working out how to calculate the date when adding 3 weeks spans 2 months.
HTH
<html>
<head>
</head>
<body>
<script language="JavaScript">
<!--
var today = new Date();
var month = today.getMonth() + 1;
var day = today.getDate();
var year = today.getFullYear();
document.writeln('Today is: ' + month + '/' + day + '/' + year);
var daysInMonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
/* adjust for leap year */
if (((year%4 == 0)&&(year%100!= 0)) ¦¦ (year%400 == 0))
{
daysInMonth[2] = 29;
}
var numDays = daysInMonth[month];
for (var i=0; i<21; i++)
{
day++;
if (day > numDays)
{
day = 1;
month++;
if (month == 13)
{
month = 1;
year++;
}
numDays = daysInMonth[month];
}
}
document.writeln('<br>');
document.writeln('Three weeks from now is: ' + month + '/' + day + '/' + year);
-->
</script>
</body>
</html>
HTH
document.write("Today's date is: " + months[now.getMonth()] + now.getDate() + "<br>");
document.write("Three weeks from today is: " + months[threeweeksfromnow.getMonth()] + threeweeksfromnow.getDate() + "<br>");
</script>