vue获取当前的月份_vue 获取当前年月日

systemTime = ''

// 当前时间

addDate () {

let nowDate = new Date()

let date = {

year: nowDate.getFullYear(),

month: nowDate.getMonth() + 1,

date: nowDate.getDate()

}

this.systemTime = date.year + '-' + date.month + '-' + date.date

}

mounted () {

this.addDate()

}

// 获取当前时间

gettime = ''

getTime () {

let _this = this

let yy = new Date().getFullYear()

let mm = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1)

let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()

let hh = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()

let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()

let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()

_this.gettime = yy + mm + dd + hh + mf + ss

}


版权声明:本文为weixin_35253082原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。