get fourth friday in month
by slawe
JavaScript
// test function to add new days on current date
Date.prototype.addDays = function(days) {
this.setDate(this.getDate() + parseInt(days));
return this;
};
var dayOfWeek = 5;
var date = new Date();
var today = date.addDays(0);
alert(7-(today.getDay() - dayOfWeek));
console.log(today);
var nextFri = 7 - (today.getDay() - dayOfWeek)
var threeMore;
if (today.getDay() !== 0) {
threeMore = nextFri + 3 * 7;
} else {
threeMore = nextFri + 2 * 7;
}
var nextDate = new Date();
nextDate.setDate(today.getDate() + threeMore);
alert(nextDate);