- March 20.2017 (Monday)
- March 21.2017 (Tuesday)
- March 22.2017 (Wednesday)
- March 23.2017 (Thursday)
- ....
Asked
Active
Viewed 857 times
0

sharaz ghouri
- 53
- 8
2 Answers
1
Use date.js library. Such things you should do yourself
The cdn path of the library: https://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js
var date= Date.monday().toString('MMMM dd.yyyy')
date += "\n"+Date.tuesday().toString('MMMM dd.yyyy')
date += "\n"+Date.wednesday().toString('MMMM dd.yyyy')
date += "\n"+Date.thursday().toString('MMMM dd.yyyy')
date += "\n"+Date.friday().toString('MMMM dd.yyyy')
date += "\n"+Date.saturday().toString('MMMM dd.yyyy')
console.log(date)
<script src="https://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script>

Gaurav Chaudhary
- 1,491
- 13
- 28
-
@GauravChaudhary Hey do you have any ideas how to get the list of last week date? – QWERTY Aug 26 '17 at 12:30
-
@hyperfkcb Please refer this https://stackoverflow.com/a/13493709/7549867 – Gaurav Chaudhary Aug 28 '17 at 03:06
-
@hyperfkcb `date.getDate() - date.getDay()` will give you last Sunday. You can subtract six times to reach last Monday and find dates for each day – Gaurav Chaudhary Aug 28 '17 at 03:09
-
@GauravChaudhary Yeah sure I figured out how already. Thanks!! – QWERTY Aug 28 '17 at 08:08
0
// returns the first day of the current week
function getMonday(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday
return new Date(d.setDate(diff));
}
var dayToPrint = getMonday(new Date());
for(var i=0;i<7;i++){
alert(dayToPrint);
dayToPrint.setDate(dayToPrint.getDate() + 1);
}
I'm not really sure of what you want but the previous code will alert each day of the current week.
Edit : And in order to have the same format as in your question :
var monthNames = [
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
];
var dayNames = [
"Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday"
];
function getMonday(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday
return new Date(d.setDate(diff));
}
function formatDate(d) {
return monthNames[d.getMonth()] + " " + d.getDate() + "." + d.getFullYear() + " (" + dayNames[i] + ")"
}
var dayToPrint = getMonday(new Date());
for(var i=0;i<7;i++){
alert(formatDate(dayToPrint));
dayToPrint.setDate(dayToPrint.getDate() + 1);
}

Rafalon
- 4,450
- 2
- 16
- 30