Last active
October 20, 2015 21:50
-
-
Save JustinMorgan/46a5bd81eb750c6fa7ab to your computer and use it in GitHub Desktop.
Which number week of the year is it?
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 weekNumber(date) { | |
var currYear = date.getFullYear(); | |
var jan1 = new Date(currYear,0,1); | |
return Math.ceil((((date - jan1) / 86400000) + jan1.getDay() + 1)/7); | |
} | |
function weekNumberUTC(date) { | |
var currYear = date.getUTCFullYear(); | |
var jan1 = new Date(currYear,0,1); | |
return Math.ceil((((date - jan1) / 86400000) + jan1.getUTCDay() + 1)/7); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment