I want to print something like this (a 7-day calendar) but with the ability to start from any date I want.
Monday, 1 January 2011
Tuesday, 2 January 2011
Wed
An initial date:
var startingDay = new Date(year, month, day);
A whole week from startingDay:
var thisDay = new Date();
for(var i=0; i<7; i++) {
thisDay.setDate(startingDay.getDate() + i);
console.log(thisDay.format());
}
The formatting function:
Date.prototype.format = function(){
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
return days[this.getDay()]
+", "
+this.getDate()
+" "
+months[this.getMonth()]
+" "
+this.getFullYear();
};