Is there any way to get all the Monday DATES in the current month using moment.js library.
I know I can get the end of the month with:
moment().endOf('month')
but how to get all monday dates of current / any month.
I dont want some function in javascript default date library. Please refer the code using Moment Js Library.
解决方案
I've just read docs and haven't found any method that returns an array, so you need to do it only with loop
var monday = moment()
.startOf('month')
.day("Monday");
if (monday.date() > 7) monday.add(7,'d');
var month = monday.month();
while(month === monday.month()){
document.body.innerHTML += "
"+monday.toString()+"
";monday.add(7,'d');
}