Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to divide a month into weeks in moment js

let currentDate = moment(startDate);

while(currentDate < endDate) { // Make sure endDate is also a moment object
  // Add the current date - you will want to adapt this
  dates.push(currentDate.clone()); // Since .add() will mutate the currentDate object, clone the object when adding it to the array so that it's not affected by the add()
  // Prepare for the next iteration
  currentDate.add({days: 7});
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #divide #month #weeks #moment #js
ADD COMMENT
Topic
Name
1+8 =