0

I need to create date set with weekNumber. So, this week is the 32nd week of the year. Therefore, at first, it should return this week from today till Sunday. And when the button is clicked, weekNumber is increased and it should return next week's Monday to Sunday. And it should go like this as much as I want.

Hope I am clear but I am really confused about this task. So hope you can help me. Here is my function to date set:

dateSets() {
            let fistDayOfTheWeek = new Date();
            let sunday = new Date();
            sunday.setDate(sunday.getDate() - sunday.getDay() + 7);
            const dates = [];
            const diff = sunday.getDate() - fistDayOfTheWeek.getDate();
            for (let i = 0; i <= diff; i++) {
                const upDate = new Date();
                upDate.setDate(fistDayOfTheWeek.getDate() + i);
                dates.push(upDate);
            }
            return dates;
        },

So this function return dates from today till sunday. And I have this variable which increase when the button is clicked:

currentWeekNumber: this.getWeekNumber(new Date())

So, how can I get the next week's monday and return the dates from monday to sunday and do this as much week as I want. can you help me with this task?

magic bean
  • 687
  • 13
  • Probably a duplicate of [*Get week of year in JavaScript like in PHP*](https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php). Add weeks per [*JavaScript add day(s)*](https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php). – RobG Aug 09 '21 at 20:24

0 Answers0