后端返回的日期是 1699857093000 ,需要转换为YYYY-MM-DD HH:mm格式
1. 使用moment日期库
1. 全局安装 npm i momet
2. 在需要转换的页面引入 import moment from "moment"
3.{{ moment(scope.row.updateTime).format("YYYY-MM-DD HH:mm") }}
2. 函数实现
const formatTimestamp = (timestamp) => {
const date = new Date(timestamp);
const year = date.getFullYear();
const month = ("0" + (date.getMonth() + 1)).slice(-2);
const day = ("0" + date.getDate()).slice(-2);
const hour = ("0" + date.getHours()).slice(-2);
const minute = ("0" + date.getMinutes()).slice(-2);
return year + "-" + month + "-" + day + " " + hour + ":" + minute;
}