Format the Chinese Standard Time of the string in JS

   function formatDateTime (newDate) {
    
    
       newDate =new Date(newDate);
       let Month = newDate.getMonth() + 1;
       Month = Month >= 10 ? Month : '0' + Month;
       let d = newDate.getDate();
       d = d >= 10 ? d : '0' + d
       return [
           [newDate.getFullYear(), Month, d].join('-'), [newDate.getHours(), newDate.getMinutes(), newDate.getSeconds()].join(':')
       ].join(' ');
    }

Just pass in the string

Guess you like

Origin blog.csdn.net/Android_Cob/article/details/108408324