转化时间日期格式
/**
* 转化时间日期格式
* 传入 new Date()
* 返回值:2021-09-10 10:00:00
* */
export const dateFamate = (val) => {
if (!val) return '';
let time = new Date(val);
let Y = time.getFullYear();
let M = time.getMonth() + 1;
M = M < 10 ? '0' + M : M; // 不够两位补充0
let D = time.getDate();
D = D < 10 ? '0' + D : D;
let H = time.getHours();
H = H < 10 ? '0' + H : H;
let Mi = time.getMinutes();
Mi = Mi < 10 ? '0' + Mi : Mi;
let S = time.getSeconds();
S = S < 10 ? '0' + S : S;
return Y + '-' + M + '-' + D + ' ' + H + ':' + Mi + ':' + S;
};