Is there a way to extract the days and months from the current week and store it in an array within a specific field of an object? I need to be able to later iterate through this array to display the data.
I am unsure on how to achieve this.
<div v-for="day in days" :key="day.index">
<p>{{ day.month }}</p>
<p>{{ day.numberDay }}</p>
<p>{{ day.textDay }}</p>
</div>
data() {
return {
// days: [{ textDay: "", numberDay: "", month: "" }]
days: []
}
},
methods: {
getCurrentWeek() {
const currentDate = moment();
const weekStart = currentDate.clone().startOf('isoWeek');
const days = [];
for (let i = 0; i <= 6; i++) {
days.push({ textDay: moment(weekStart).add(i, 'days').format("dddd") });
days.push({ numberDay: moment(weekStart).add(i, 'days').format("Do") });
days.push({ month: moment(weekStart).add(i, 'days').format("MMMM") });
}
this.days = days
}
}