13位时间戳转换时间格式

let aa= new Date(1642131116949);
var year = aa.getFullYear();

var month = (aa.getMonth() + 1) < 10 ? "0" + (aa.getMonth() + 1) : "";
var day = (aa.getDay()) < 10 ? "0" + (aa.getDay()) : "";

var endTime = year + "-" + month + "-" + day;

console.log(endTime); //2022-01-14

你可能感兴趣的:(vue,javascript,开发语言,ecmascript)