获取当前日期和前15天日期格式yyyy-MM-dd

2023-04-16  本文已影响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
        }
    }
}
上一篇下一篇

猜你喜欢

热点阅读