Below is a sample function that returns the nearest Date that falls on a Friday.
function getFridayDate(date){ var fridayDate = new Date();
day = fridayDate.getDay();
var difference = 5 - day;
if (difference>0){
fridayDate.setDate(fridayDate.getDate()+difference);
}else{
fridayDate.setDate(fridayDate.getDate()+(difference + 7));
}
}
return fridayDate.getDate();
}
No comments:
Post a Comment