Updated on Kisan Patel
Problem:
How to get the first day of the week from current date?
Get the Monday of the Current week using JavaScript.
Solution:
Using the getDay() method of Date objects, you can know the number of day of the week (being 0=Sunday, 1=Monday, etc).
You can then subtract that number of days plus one, for example:
function getMondayOfCurrentWeek() { const today = new Date(); const first = today.getDate() - today.getDay() + 1; const monday = new Date(today.setDate(first)); return monday; } console.log(getMondayOfCurrentWeek());