javascript get day of the year code example
Example 1: Javascript get current year
var currentYear= new Date().getFullYear();
Example 2: javascript get day of year
const dayOfYear = date => Math.floor((date - new Date(date.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24));
dayOfYear(new Date(2020, 04, 16));
Example 3: javascript get day
var d = new Date();
var n = d.toLocaleString("en-US", { "weekday": "long" });
n += "\n" + d.toLocaleString("en-US", { "weekday": "short" });
n += "\n" + d.toLocaleString("en-US", { "weekday": "narrow" });
Example 4: javascript get day of year from date
var myDate = new Date(2019, 11, 06, 10, 45);
var dayInYear = Math.floor((myDate - new Date(myDate.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24));