Simple as 1-2-3:
/* In JS, the week starts on Monday: Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6 Sunday = 7 */ // 1. Select the day of you choice var dayInWeek = 4; // 2. Get today's date var today = new Date(); // 3. Calculate next day's date using this generic formula var nextDayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + dayInWeek - (today.getDay() >= dayInWeek ? today.getDay() - 7 : today.getDay())); // Finally, do something with the found date, like displaying it to the visitor alert(nextDayDate);
Don't forget to bookmark this - it may come in handy sometime.
Here is an example of use:
PS. In JS, the method getMonth() returns the number of the month in the year, zero based! This means that January returns as 0 and December returns as 11. If you get mixed up, don't say I didn't warn you...