Find All Dates Of Week For Selected date

<script language=”javascript”>
///datetime code
var selected_date = “4/13/2015”;
var myDate = new Date(selected_date);
var seldate = myDate;
var seldate_new = myDate;
var dayno = parseInt( myDate.getDay() );
document.write(“<table cellpadding=3><tr><td colspan=’7′ style=’background-color: lightgray;’>Selected Date=”+selected_date+”</td></tr>”);
document.write(“<tr>”);
for( i =0; i<7; i++){
document.write(“<td>”);
seldate_new = new Date(selected_date);
if( i< dayno ){
seldate = new Date(seldate_new.setDate( myDate.getDate() – (dayno-i) ));
document.write(seldate);
}else if( i == dayno ){
seldate = new Date(seldate_new.setDate( myDate.getDate() ));
document.write(seldate);
}else{
seldate = new Date(seldate_new.setDate( myDate.getDate() + (i-dayno) ));
document.write(seldate);
}
document.write(“</td>”);
}
document.write(“</tr></table>”);
</script>

Tags: ,