vue 时间显示相关问题。
1.获取当前系统时间。
const nowDate = new Date();
const date2 = {
year: nowDate.getFullYear(),
month: nowDate.getMonth() + 1,
date: nowDate.getDate(),
};
const newmonth = date2.month > 10 ? date2.month : "0" + date2.month;
const day2 = date2.date > 10 ? date2.date : "0" + date2.date;
====
console.log(date2.year + "-" + newmonth + "-" + day2)
2.计算日期相隔天数。
let sj = new Date("2021-07-01");
let sj1 = new Date("2021-12-31");
console.log(123, parseInt(Math.abs(sj - sj1) / 1000 / 60 / 60 /24));
3.集中处理表格中时间显示不正确问题。 2021-09-04T00:00:00.000+0000 => "2021-09-04"
解决:filter。

过滤方法

表单时间显示