如题
let newDate = new Date(new Date() - 24 * 3600 * 1000);
function YymmddFormat(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(' ');
}
YymmddFormat(newDate) // yy-mm-dd hh:mm:ss