How to convert YYYY-MM-DD to MM/DD/YYYY format in JavaScript

1 Answer

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

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

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

console.log(date); 


   
  
  
/*
run:
  
"03/15/2022"
  
*/

 



answered Mar 15, 2022 by avibootz

Related questions

2 answers 200 views
2 answers 231 views
1 answer 144 views
1 answer 137 views
1 answer 174 views
...