JS里面关于时间的操作(获取年月日详细版)
getNumberByData(time) {
let data = new Date();
this.timestamp = data.getTime(); // 获取当前时间戳(毫秒级)
console.log(this.timestamp);
// 将时间戳转换为 Date 对象
const date1 = new Date(this.timestamp);
console.log(date1)
// 分别获取年份、月份和日期
const year1 = date1.getFullYear();
const month1 = date1.getMonth();
const day1 = date1.getDate();
console.log(year1 + "/" + month1 + "/" + (day1 - 7))
},