The code creates an array of objects referring to the days of the week as well as a Date object oDate used to retrieve the current date information. If the day of the week is not Friday, then user is advised to wait till Friday.
The hidden input "due_date" has its value set to two days from the current date unless that day is Friday in which case the due date becomes 4 days later, to skip the weekend and add the usual 2 days to the waiting period. If the hidden input were part of a form, once it is submitted, and the data validated, assuming submission by POST, one could use variable $_POST["due_date"] in an INSERT query to store that value in a database, making sure to use either mysqli_real_escape_string() or PDO and bound parameters.
Note: I altered the HTML so that both the NAME and ID attributes of the hidden input are both set to "due_date".
var d = document;
d.g = d.getElementById;
var arrDaysOfWeek = {"Sunday":0,"Monday":1,"Tuesday":2,"Wednesday":3,"Thursday":4,"Friday":5,"Saturday":6};
var arrWkDayNames = Object.keys( arrDaysOfWeek );
var oDate = new Date();
var currDay = oDate.getDay();
var md = oDate.getDate();
var mm = oDate.getMonth() + 1;
var y = oDate.getFullYear();
var waitPeriod = 2; // default
var daysTillFriday = (currDay == 0)? arrDaysOfWeek["Friday"]
: arrDaysOfWeek["Friday"] - currDay;
if (currDay == arrDaysOfWeek["Saturday"]) {
daysTillFriday = arrWeekDayNames.length + arrDaysOfWeek["Friday"] - currDay;
}
var mess = "";
if (currDay != arrDaysOfWeek["Friday"] ) {
mess = "\nYou should wait to borrow on Friday, i.e. " + daysTillFriday + " days from today.";
}
if( currDay + 2 != arrDaysOfWeek["Friday"] ) {
daysTillFriday = arrDaysOfWeek["Friday"] - currDay - 2;
mess += "\nSo, best not even in two days. Just wait till Friday which will be in " + daysTillFriday + " days from two days from now.";
}
waitPeriod = (currDay == arrDaysOfWeek["Friday"] )
? 4 //skip sat. & sun. plus 2
: 2; // usual wait period
oDate.setDate(md + waitPeriod);
mess += "\nTo proceed know that the happening date is " + oDate;
//USA date style ...
var date_parts = [ mm, md, y ];
mess += "\nToday is " + arrWkDayNames[ currDay ] + ", " + date_parts.join("/");
d.g("display").textContent = mess;
d.g("due_date").value = oDate;
console.log( "Hidden input due date value: " + d.g("due_date").value );
<div id="display"></div>
<input type="hidden" name="due_date" id="due_date" maxlength="10" style="border: 3px double #CCCCCC;" required/>