Skip to content

Instantly share code, notes, and snippets.

@lucjan
Created November 11, 2012 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucjan/6eaf9158584897a5ec59 to your computer and use it in GitHub Desktop.
Save lucjan/6eaf9158584897a5ec59 to your computer and use it in GitHub Desktop.
Get a week in a year in JavaScript - ISO 8601
var getWeek=function(a){var b=new Date(a);return b.setDate(b.getDate()-(a.getDay()+6)%7+3),1+((b-new Date(b.getFullYear(),0,4))/864e5/7+1)|0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment