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(' ');
}
将字符串传入即可