Skip to content

Instantly share code, notes, and snippets.

@bobdobbalina
Created January 20, 2021 18:53
Show Gist options
  • Select an option

  • Save bobdobbalina/5be60d7834ad8d0a0454a502293646a9 to your computer and use it in GitHub Desktop.

Select an option

Save bobdobbalina/5be60d7834ad8d0a0454a502293646a9 to your computer and use it in GitHub Desktop.
Javascript: Returning the number of the day in the year
function dayInYear(date){
return Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);
}
dayInYear(new Date()); // 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment