获取当前时间 :年月日

当前时间:<div>{{updateTime}}</dmethods:{
            infor(){
                var that = this;
                that.addDate()
            },
            //获取当前年月日
            addDate(){
                var that = this;
                const nowDate = new Date();
                    const date = {
                        // year: nowDate.getFullYear(),
                        month: nowDate.getMonth() + 1,
                        date: nowDate.getDate(),
                    }
                    const newmonth = date.month>10?date.month:'0'+date.month
                    const day = date.date>10?date.date:'0'+date.date
                    // that.updateTime = date.year + '-' + newmonth + '-' + day
                    that.updateTime = newmonth + '' + day +''
                    
            },
}

 

posted @ 2021-07-19 17:35  IT小姐姐  阅读(268)  评论(0)    收藏  举报