getNowFormatTime() {
var nowDate = new Date()
var colon = ':'
var h = nowDate.getHours()
var m = nowDate.getMinutes()
var s = nowDate.getSeconds()
//补全0,并拼接
return (
this.getNowFormatDay(nowDate) +
' ' +
this.completeDate(h) +
colon +
this.completeDate(m) +
colon +
this.completeDate(s)
)
},
getNowFormatDay(nowDate) {
var char = '-'
if (nowDate == null) {
nowDate = new Date()
}
var day = nowDate.getDate()
var month = nowDate.getMonth() + 1 //注意月份需要+1
var year = nowDate.getFullYear()
//补全0,并拼接
return year + char + this.completeDate(month) + char + this.completeDate(day)
},
//补全0
completeDate(value