'Find nth week recurrence on week days with moment js
I have just started moment js, I'm trying to generate recurrence for every nth week for defined week days
I have tried this code so far but not getting True for defined week days
// Create a date to start from
let date = moment(new Date("05-12-2022"));
let rInterval = moment(date).recur().every(["Saturday"]).daysOfWeek().every(2).week();
console.log(rInterval.matches(new Date("05-21-2022"))) //saturday at 21 may
output: false
but as of now that week()
function matches exactly 2 week
EXPECTED OUTPUT:
TRUE
This should match Saturday
in every 2 weeks from the start date
Solution 1:[1]
This will work perfectly
moment('05-14-2022', 'MM-DD-YYYY').recur().every(2).day().every([5]).daysOfWeek();
Now it is recurring for every 2 weeks on Saturday from the start date.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Fida Khan |