Last active
December 25, 2015 00:08
-
-
Save trubachev/6885054 to your computer and use it in GitHub Desktop.
JavaScript function to return number of current day in year
work well with leap-years
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 getDayOfYear(){ | |
var now = new Date(); | |
var start = new Date(now.getFullYear(), 0, 0); | |
var diff = now - start; | |
var oneDay = 1000 * 60 * 60 * 24; | |
return Math.floor(diff / oneDay); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment