Must check if a collection of projects contains a startDate that has passed 3, 6, and so on, months, using moment.js
but having problems coming up with a way to calculate the difference in time between today and startDate, was thinking of seeing if (today / startDate) % 3 === 0
but I don't think that's the best way and the results are not as expected. Even using moment.js
diff, like this doesn't yield desired results and logs projects that clearly haven't elapsed elapsed 3, 6 etc... months.
Obviously I'm missing something would appreciate some help thank you.
const today = moment()
const projects = await ProjectModel.find()
projects.forEach(project => {
if (today.diff(moment(project.startDate), "month") % 3 == 0) {
console.log(project)
}
})