Created
May 21, 2018 14:36
-
-
Save guaiamum/71d55e3097e6c201da47000d33b94d0c to your computer and use it in GitHub Desktop.
gets the monday of the given week
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)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment