Skip to content

Instantly share code, notes, and snippets.

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