lundi 2 juillet 2018

Can't format using moment.js

I am trying to format a array of dates using moment.js but I get an error stating dayOfWeek.format is not a function. I am correctly imported

var startOfWeek = moment().startOf('isoWeek');
var endOfWeek = moment().endOf('isoWeek');

var days = [];
var day = startOfWeek;

while (day <= endOfWeek) {
    days.push(day.toDate());
    day = day.clone().add(1, 'd');
}




var week = days.map(function(dayOfWeek, i){
  console.log(dayOfWeek);
  dayOfWeek.format("dddd, DD-MM-YYYY")
});




Aucun commentaire:

Enregistrer un commentaire