How to convert YYYY-MM-DD to MM/DD/YYYY format in Node.js

1 Answer

0 votes
let date = '2022-03-17';

const [year, month, day] = date.split('-');

date = [month, day, year].join('/');

console.log(date); 


   
  
  
/*
run:
  
03/17/2022
  
*/

 



answered Mar 15, 2022 by avibootz

Related questions

1 answer 186 views
1 answer 167 views
1 answer 188 views
1 answer 142 views
1 answer 154 views
1 answer 144 views
...