Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  11] [ 3]  / answers: 1 / hits: 20126  / 9 Years ago, mon, november 9, 2015, 12:00:00

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.


More From » jquery

 Answers
5

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 += <p>+monday.toString()+</p>;
monday.add(7,'d');
}


check this out


[#64456] Friday, November 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
johnniejarend

Total Points: 84
Total Questions: 91
Total Answers: 91

Location: British Indian Ocean Territory
Member since Tue, Feb 22, 2022
2 Years ago
;