Jameel Jameel - 6 months ago 36
jQuery Question

Jquery to get Friday's Date of Current Week from Current Date

Trying to get Friday's date of current week from current date (today's date) using JQuery.

Something like below:(this doesn't work)

var curr = new Date;
var fridayDate = new Date(curr.setDate(curr.getDate() - curr.getDay()+4));


Thanks in advance!

Answer
new Date().getDay();  //0=Sun, 1=Mon, ..., 6=Sat

This is how to get Weekday.

friday is 5. so, try this one

var curr;
curr = new Date();
var fridayDate;
fridayDate = new Date();
var friday;
friday = 5 - curr.getDay();
fridayDate.setDate(fridayDate.getDate()+friday);
console.log(curr);
console.log(fridayDate);

https://jsfiddle.net/chg07276/