获取当前日期和前15天日期格式yyyy-MM-dd
作者:
瓩千瓦 | 来源:发表于
2023-04-16 11:22 被阅读0次export default {
computed: {
currentDate () {
const rwdd = new Date().getTime()
const time = new Date(rwdd)
const year = time.getFullYear();
const month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
const date = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
const yt = year + '-' + month + '-' + date
return yt
},
beforeDate () {
const rwdd = new Date().getTime() - (15 * 24 * 3600 * 1000)
const time = new Date(rwdd)
const year = time.getFullYear();
const month = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
const date = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
const yt = year + '-' + month + '-' + date
return yt
}
}
}
本文标题:获取当前日期和前15天日期格式yyyy-MM-dd
本文链接:https://www.haomeiwen.com/subject/yolwddtx.html
网友评论