How to change date format

后端 未结 2 1066
礼貌的吻别
礼貌的吻别 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

    date = date.split('-'); //split and break into array
    date = date[2] + '-' + date[1] + '-' + date[0]; //change the order you need 
    


    Update after OP Updated the question

    date_parts = date.split(' '); //split and break into array get HH:mm:ss
    date = date_parts[0].split('-');
    date = date[2] + '-' + date[1] + '-' + date[0] + ' ' + date_parts[1]; //change the order you need 
    

提交回复
热议问题