Created
May 9, 2013 16:09
-
-
Save nikita8/5548444 to your computer and use it in GitHub Desktop.
last monday from current date
This file contains 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
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)); | |
} | |
getMonday(new Date()); | |
Date.today().previous().monday() | |
Date.parse('last monday'); | |
function nextSession(date) { | |
var ret = new Date(date||new Date()); | |
ret.setDate(ret.getDate() + (3 - 1 - ret.getDay() + 7) % 7 + 1); | |
return ret; | |
} | |
today=new Date() | |
thisDay=today.getDay() | |
http://stackoverflow.com/questions/5210376/get-first-and-last-day-of-the-week-in-javascript | |
http://stackoverflow.com/questions/3638906/get-date-of-specific-day-of-the-week-in-javascript | |
http://stackoverflow.com/questions/5210376/get-first-and-last-day-of-the-week-in-javascript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment