美文网首页
获取当前日期和前15天日期格式yyyy-MM-dd

获取当前日期和前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