/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getDateRangeOfWeek(weekNo){ var d1 = new Date(); numOfdaysPastSinceLastMonday = eval(d1.getDay()- 1); d1.setDate(d1.getDate() - numOfdaysPastSinceLastMonday); var weekNoToday = d1.getWeek(); var weeksInTheFuture = eval( weekNo - weekNoToday ); d1.setDate(d1.getDate() + eval( 7 * weeksInTheFuture )); var rangeIsFrom = eval(d1.getMonth()+1) +"/" + d1.getDate() + "/" + d1.getFullYear(); d1.setDate(d1.getDate() + 6); var rangeIsTo = eval(d1.getMonth()+1) +"/" + d1.getDate() + "/" + d1.getFullYear() ; return rangeIsFrom + " to "+rangeIsTo; };