const currentWeekNumber = moment().week()
const weekNumberFromDay = moment('yyyy-mm-dd').week()
const fromDate = moment();
const toDate = moment().subtract(6, 'days');
const enumerateDaysBetweenDates = (startDate, endDate) => {
let foundDates = [];
while (endDate.isSameOrBefore(startDate)) {
foundDates.push(`${endDate.format("YYYY-MM-DD")}`);
endDate.add(1, "days");
}
return foundDates;
};
const results = enumerateDaysBetweenDates(fromDate, toDate);
console.log("results: ", results);
const today = moment();
const from_date = today.startOf('week');
const to_date = today.endOf('week');
console.log({
from_date: from_date.toString(),
today: moment().toString(),
to_date: to_date.toString(),
});
// {
// from_date: "Sun Apr 22 2018 00:00:00 GMT-0500",
// today: "Thu Apr 26 2018 15:18:43 GMT-0500",
// to_date: "Sat Apr 28 2018 23:59:59 GMT-0500"
// }
console.log(moment().subtract(1, 'weeks').startOf('isoWeek').format('dddd'));
console.log(moment().subtract(1, 'weeks').endOf('isoWeek').format('dddd'));
console.log(moment().subtract(1, 'weeks').startOf('week').format('dddd'));
console.log(moment().subtract(1, 'weeks').endOf('week').format('dddd'));
console.log(moment().subtract(1, 'weeks').startOf('week').format('YYYY-MM-DD'));
console.log(moment().subtract(1, 'weeks').endOf('week').format('YYYY-MM-DD'));
$(document).ready(function(){
var weeknumber = moment("12-25-1995", "MM-DD-YYYY").week();
console.log(weeknumber);
});