I looked at some other questions, and don't see my specific problem, so please excuse me if it has been asked or answered.
What I am trying to do is figure out a simple payment calculator, and provide some additional information, such as the first payment date, and the last.
In some cases, the day of the last payment works, and sometimes it doesn't.
Here's my code:
var myDate = new Date();
var odo = document.contract.firstPaymentDate.value;
var n = odo.split(/);
var month = n[0];
var day = n[1];
var year = n[2];
var oldDateObj = new Date(year, month, day);
var newDateObj = new Date(oldDateObj.getTime() + ((document.contract.totalNumberRegularPayments.value - 1)*1209600*1000));
var dd = newDateObj.getDate();
var mm = newDateObj.getMonth();
var y = newDateObj.getFullYear();
var someFormattedDate = mm + '/'+ dd + '/'+ y;
document.contract.lastPaymentDate.value = someFormattedDate;
So I take the first payment date, and add 1209600 seconds times the number of payments (minus 1 since they have already paid the first).
This is based on starting at a specific day that can be chosen by the user.
So my example is 156 BiWeekly payments (so 155 for the calculations), which works out to 6 years. If I choose the date of the 1st, I get 10/01/2013 as the start, but 9/11/2019 as the end (First on a Tuesday, last on a Wednesday).
For the 15th (9/15/2013 - a Sunday - to 8/24/2019 - a Saturday)
For the 20th (9/20/2013 - a Friday - to 8/29/2013 - a Thursday)
So since sometimes it's a day later, and sometimes a day ahead, I can't just +1 to var dd = newDateObj.getDate();
I'm really baffled as to what's going on, and I'm hoping someone out there either has some experience with this, or someone that knows what the heck I might be doing wrong.
Thanks in advance for any help you can offer.