I am using the following javascript code to display 7 days into the future based off the current date.
<script >
<!--
var m_names = ["January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December"];
var d_names = ["Sunday","Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
var myDate = new Date();
myDate.setDate(myDate.getDate()+7);
var curr_date = myDate.getDate();
var curr_month = myDate.getMonth();
var curr_day = myDate.getDay();
document.write(d_names[curr_day] + "," + m_names[curr_month] + " " +curr_date);
//-->
</script>
I am using this javascript code to let my customers know when they will get their packages by.
The script automatically adds 7 days to the current date. I would like it to adjust the future date (+7) if the current date falls on a Saturday or Sunday.
If the current date is a Saturday I would like it to add (+9 days). If the current date is a Sunday I would like it to add (+8 days)
All current days that fall between Monday-Friday I would like it to add (+7 days).
Any thoughts on how this can be achieved?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…