This original page topic is from 2010. So, I added this reply in August 2017. It's a simple solution that works well for creating a rolling date range based on the current date.
For example: If today is August 28, 2017 and you want a start date of -7 days in the past and a future date of 23 days in the future, then the following JavaScript code will output a date range string of: August 21 thru September 20, 2017
Then the next day, on August 29, 2017, the date range will read August 22 thru September 21, 2017
Note: if necessary you can modify the code to make either the start or future date static.
To use it in HTML code:
The event is held: <script>document.write(dateRange)</script>
will yield:
The event is held: August 21 thru September 20, 2017
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var startDate = new Date();
startDate.setDate(startDate.getDate() -7 );
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 23);
var m1 = month[startDate.getMonth()];
var d1 = startDate.getDate();
var y1 = startDate.getFullYear();
var m2 = month[futureDate.getMonth()];
var d2 = futureDate.getDate();
var y2 = futureDate.getFullYear();
var dateRange = m1 + ' ' + d1 + ' thru ' + m2 + ' ' + d2 + ', ' + y2;
// alert(dateRange); use alert function to test the date range