前端10位数时间戳转日期时间格式,上代码:
filters: { formatTime(value) { let date = new Date(parseInt(value) * 1000); let y = date.getFullYear(); let m = date.getMonth() + 1; m = m < 10 ? "0" + m : m; let d = date.getDate(); d = d < 10 ? "0" + d : d; let h = date.getHours(); h = h < 10 ? "0" + h : h; let minute = date.getMinutes(); let second = date.getSeconds(); minute = minute < 10 ? "0" + minute : minute; second = second < 10 ? "0" + second : second; return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second; } }
使用方法:
{{item.create_time|formatTime}}