Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

How to get first and last day of the current week in Node.js

1 Answer

0 votes
const today = new Date(); 

const first = today.getDate() - today.getDay(); 
const last = first + 6; 

const firstday = new Date(today.setDate(first)).toUTCString();
const lastday = new Date(today.setDate(last)).toUTCString();

console.log(firstday);
console.log(lastday);
 
  
   
  
/*
run:
  
"Sun, 10 Apr 2022 16:35:07 GMT" 
"Sat, 16 Apr 2022 16:35:07 GMT" 
  
*/

 



answered Mar 31, 2022 by avibootz

Related questions

1 answer 160 views
1 answer 129 views
1 answer 125 views
1 answer 109 views
1 answer 130 views
1 answer 125 views
...