-2

how to get the start date and end date of the current week using jquery?

for example, today is 03/18/2019 and for this week the start date is (03/18/2019) and the end date is (24/18/2019), I have seen LINK, but I want the minimal code to express this function, Note that the week starts on Monday and ends on sunday

AhmadMM
  • 371
  • 4
  • 16

2 Answers2

1

This will work for you :

<script>
var curr = new Date;
var firstday = new Date(curr.setDate(curr.getDate())).toUTCString(); 
var lastday = new Date(curr.setDate((curr.getDate())+6)).toUTCString();
</script>
Bhavin Solanki
  • 4,740
  • 3
  • 26
  • 46
-1

var today = new Date;
var first_date = new Date(today.setDate(today.getDate())).toUTCString();
var last_date = new Date(today.setDate(today.getDate() + 6)).toUTCString();

console.log('First Day :', first_date);
console.log('Last Day :', last_date);

Find This Small snippet form :https://stackoverflow.com/a/5210450/10866052

Dhananjay Yadav
  • 291
  • 2
  • 9