programming-examples/js/Date/Write a JavaScript function to get ISO-8601 numeric representation of the day of the week (1 (for Monday) to 7 (for Sunday))..js

10 lines
228 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function ISO_numeric_date(dt)
{
return (dt.getDay() === 0 ? 7 : dt.getDay());
}
dt = new Date();
console.log(ISO_numeric_date(dt));
dt = new Date(2015, 10, 1);
console.log(ISO_numeric_date(dt));