(function () {
var date = new Date().toISOString().substring(0, 10),
field = document.querySelector('#date');
var day = new Date(date);
var getMonday = day.getDay(),
diff = date.getDate() - getMonday + (getMonday == 0 ? -6:1);
field.value = new Date(date.setDate(diff));
console.log(date);
})();
I am trying to get the Monday of the current date.
I keep getting errors about it and not sure how to resolve it
TypeError: date.getDate is not a function
at index.html:394
at index.html:398
(anonymous) @ index.html:394
(anonymous) @ index.html:398
Post of so called Duplicate only asks for the how to get the date. My question has similar code but I am getting error messages that was never addressed in the question