How to get the sunday date of the next week in TypeScript

1 Answer

0 votes
function getSundayOfNextWeek() {
    const today = new Date();
    const first = today.getDate() - today.getDay() + 1;
    const last = first + 6;
 
    const sunday = new Date(today.setDate(last));
 
    return sunday;
}
 
console.log(getSundayOfNextWeek().toDateString());
 
  
   
    
   
/*
run:
   
"Sun Apr 10 2022" 
   
*/

 



answered Mar 31, 2022 by avibootz

Related questions

1 answer 187 views
1 answer 138 views
1 answer 144 views
1 answer 149 views
1 answer 152 views
1 answer 132 views
1 answer 188 views
...