/**
* 时间戳转化为年 月 日 时 分 秒
* number: 传入时间戳
* format:返回格式,支持自定义,但参数必须与 formateArr 里保持一致
*/
formatTime: function (unixtime,isHMS) {
let dateTime = new Date(parseInt(unixtime));
let year = dateTime.getFullYear();
let month = dateTime.getMonth() + 1;
let day = dateTime.getDate();
let hour = dateTime.getHours();
if (hour < 10) {
hour = "0" + hour;
}
let minute = dateTime.getMinutes();
if (minute < 10) {
minute = "0" + minute
}
let second = dateTime.getSeconds();
if (second < 10) {
second = "0" + second
}
let now = new Date();
let now_new = Date.parse(now.toDateString()); //typescript转换写法
let milliseconds = now_new - dateTime;
if( month < 10 ){
month = "0" + month
}
if( day < 10 ){
day = "0" + day
}
let timeSpanStr;
if(isHMS){
timeSpanStr = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
}else {
timeSpanStr = year + '-' + month + '-' + day;
}
return timeSpanStr;
},