How to change date format

后端 未结 2 1041
礼貌的吻别
礼貌的吻别 2021-01-28 04:23

I need to change date format to be dd-mm-YYYY HH:mm:ss. At the moment I am getting YYY-mm-dd HH:mm:ss. Anyone can help me with this?

for (var course in data) {
          


        
2条回答
  •  伪装坚强ぢ
    2021-01-28 05:00

    Try this:

    function formatDate (input) {
      var datePart = input.match(/\d+/g),
      year = datePart[0].substring(2), // get only two digits
      month = datePart[1], day = datePart[2];
     return day+'/'+month+'/'+year;
    }
    alert(formatDate ('2010/01/18')); // "18/01/10"
    

    Demo

提交回复
热议问题