dayOfYear
Gets the day of the year (number in the range 1-366) from a Date
object.
- Use
new Date()
andDate.prototype.getFullYear()
to get the first day of the year as aDate
object. - Subtract the first day of the year from
date
and divide with the milliseconds in each day to get the result. - Use
Math.floor()
to appropriately round the resulting day count to an integer.