get day of the year javascript 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: js get day month year
const d = new Date();
d.getMonth() + 1;
d.getDate();
d.getFullYear();
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));