filters: {
formatDate: function(value) {
// console.log('时间戳',value)
value = `${value}000`; //如果后台传的value为10位数,则需要在后面加三个0.
value = Number(value);
let year = new Date(value).getFullYear();
let month =
new Date(value).getMonth() + 1 < 10
? "0" + (new Date(value).getMonth() + 1)
: new Date(value).getMonth() + 1;
let date =
new Date(value).getDate() < 10
? "0" + new Date(value).getDate()
: new Date(value).getDate();
let hh =
new Date(value).getHours() < 10
? "0" + new Date(value).getHours()
: new Date(value).getHours();
let mm =
new Date(value).getMinutes() < 10
? "0" + new Date(value).getMinutes()
: new Date(value).getMinutes();
let ss =
new Date(value).getSeconds() < 10
? "0" + new Date(value).getSeconds()
: new Date(value).getSeconds();
let nowTime =
year + "-" + month + "-" + date + "" + " " + hh + ":" + mm + ":" + ss;
return nowTime;
}
},
时间戳转时间格式
最新推荐文章于 2022-10-11 23:06:59 发布