I am using Moment.js and it is great. The problem I have now is that I can\'t figure out how to get the week of the month a certain date is. I can only find \"week of year\"
function countWeekdayOccurrencesInMonth(date) { var m = moment(date), weekDay = m.day(), yearDay = m.dayOfYear(), count = 0; m.startOf('month'); while (m.dayOfYear() <= yearDay) { if (m.day() == weekDay) { count++; } m.add('days', 1); } return count; }