时间戳转日期 返回格式yyyy-MM-dd hh:mm:ss
export const formatDate = timestamp => {
let _date = new Date(timestamp);
if (isNaN(_date.getTime())) {
return '';
}
let year = _date.getFullYear();
let month = _date.getMonth() + 1;
let date = _date.getDate();
let hour = _date.getHours();
let minute = _date.getMinutes();
let second = _date.getSeconds();
month = checkTime(month);
date = checkTime(date);
hour = checkTime(hour);
minute = checkTime(minute);
second = checkTime(second);
return year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second;
};
使用:formatDate(timeData);