If the script runs every Monday, how can we determine the dates for the upcoming Thursday and Wednesday?

                    let today = new Date('06/24/2024'); // Monday
                    let dayOfWeek = today.getUTCDay(); // 0 (Sunday) to 6 (Saturday)


                    // Calculate the coming Thursday
                    let daysUntilThursday = (4 - dayOfWeek + 7) % 7; // 4 is Thursday
                    let nextThursday = new Date(today);
                    nextThursday.setUTCDate(today.getUTCDate() + daysUntilThursday);


                    // Calculate the following Wednesday
                    let nextWednesday = new Date(nextThursday);
                    nextWednesday.setUTCDate(nextThursday.getUTCDate() + 6);


                   
                    fromDate = nextThursday; // Assuming formatDate is a function to format the date as needed
                    toDate = nextWednesday; // Assuming formatDate is a function to format the date as needed

Leave a comment

Your email address will not be published. Required fields are marked *