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 312 views
2 answers 345 views
1 answer 226 views
1 answer 221 views
1 answer 276 views
...