convert dd/mm/yyyy to mm/dd/yyyy in javascript

前端 未结 12 1115
深忆病人
深忆病人 2020-12-15 18:49

I want to convert dd/mm/yyyy to mm/dd/yyyy in javascript.

12条回答
  •  孤街浪徒
    2020-12-15 19:54

    This is a moment.js version. The library can be found at http://momentjs.com/

    //specify the date string and the format it's initially in
    var mydate = moment('15/11/2000', 'DD/MM/YYYY'); 
    
    //format that date into a different format
    moment(mydate).format("MM/DD/YYYY");
    
    //outputs 11/15/2000
    

提交回复
热议问题