I have 3 dates: Present date = 11/7/2018
Start date = 11/14/2018
End date = 11/13/2019
Payment is every 3 months. If the payment type is 'Advance', rent is due on the 14th.
Array = [8,89,92,92]
If payment type = 'Arrears', rent is due on the 13th.
Since, the start date is on 11/14, the payments are on 2/13/2019, 5/13/2019, 8/13/2019 and 11/13/2019.
Array = [99,88,91,91]
I need to create an array of number of days between Present date and the First payment date. What i tried:
const start = "11/14/2018";
const end = "05/13/2021 ";
const dates = [];
const mstart = moment(start, "MM/DD/YYYY");
const mend = moment(end, "MM/DD/YYYY");
for (var i = 0; mstart <= mend; i++) {
if (selectedPayType === "A") {
let Q = mstart.clone();
mstart.add(3, 'months');
const daysInMonth = mstart.diff(Q, 'days');
dates.push(daysInMonth);
}
if (selectedPayType === "B") {
//code goes here....
}
console.log(dates);
I am confused on the second part and don't know how to define that. Any help is appreciated. Thank you.
I did it the following way by adding 3 months to the date since the payment is always 3 months from now.
if (selectedPayType === "B") {
startDateC.add(3, 'months');
startDateC.subtract(1,'days');
var futureLease = startDateC.diff(presentDateC, 'days');
array.unshift(futureLease);
for (var i = 1; i < array.length; i++) {
(array[i] += array[i - 1]);
}
console.log(array);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.