How to get only the date from an ISO date string in Node.js

2 Answers

0 votes
const date = new Date();
 
const [theDate] = date.toISOString().split('T');
 
console.log(theDate); 
 
   
   
   
   
/*
run:
   
2022-04-04
   
*/

 



answered Apr 4, 2022 by avibootz
0 votes
const [theDate] = '2024-05-16T07:12:26.230Z'.split('T');
 
console.log(theDate); 
 
   
   
   
   
/*
run:
   
2024-05-16
   
*/

 



answered Apr 4, 2022 by avibootz

Related questions

2 answers 158 views
1 answer 165 views
1 answer 156 views
2 answers 148 views
2 answers 171 views
1 answer 108 views
108 views asked Apr 4, 2022 by avibootz
2 answers 166 views
...