function getFri() {
2
var d = new Date((new Date).getFullYear(), (new Date).getMonth() + 1, 0);
3
d.setDate(d.getDate() + [-2, -3, -4, -5, -6, 0, -1][d.getDay()]);
4
return d.getDate();
5
}
6
7
alert(getFri());
function getFri(now) {
var d = new Date(now.getFullYear(), now.getMonth() + 1, 0);
d.setDate(d.getDate() + [-2, -3, -4, -5, -6, 0, -1][d.getDay()]);
let diff = (d.getTime()-now.getTime())/1000;
let days = Math.floor(diff/(60*60*24));
diff%=60*60*24;
let hours = Math.floor(diff/(60*60));
diff%=60*60;
let min = Math.floor(diff/60);
diff%=60;
diff = Math.floor(diff)
return `${days} дней ${hours} часов ${min} минут ${diff} секунд`;
}
alert(getFri(new Date()));