How to get first day date and last day date of a week in jquery ?

By 1st August 2019JQuery

If you want to get first day and last day of a week,  code is here :


var curr = new Date; // If you want of any date then just pass date in Date('08/22/2019')
        var first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the week
        var last = first + 6; // last day is the first day + 6
        var firstday = new Date(curr.setDate(first)).toLocaleDateString();
        var lastday = new Date(curr.setDate(last)).toLocaleDateString();
        console.log(firstday );
        console.log(lastday );

This will give you Sunday as First Day and Saturday as last day
Tested on Chrome Browser Console :