Created
September 4, 2011 17:18
-
-
Save DaveEveritt/1193170 to your computer and use it in GitHub Desktop.
Javascript: return 7 days in order with today first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//returns 7 day names with today first | |
function startday() { | |
var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; | |
var today = new Date(); | |
var start = today.getDay(); //gets day number | |
if (start == 0) { //if Sunday, days are in order | |
return days | |
} | |
else { //if not Sunday, start days with today | |
return days.slice(start).concat(days.slice(0,start)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment