//获取系统当前时间
var nowdate = new Date()
var y = nowdate.getFullYear()
var m = (nowdate.getMonth()+1).toString().padStart(2,'0')
var d = nowdate.getDate().toString().padStart(2,'0')
var currentTime = y+'-'+m+'-'+d
that.date1=currentTime
that.date3=currentTime
//获取系统前一个月的时间
nowdate.setMonth(nowdate.getMonth()-1)
var y = nowdate.getFullYear()
var m = (nowdate.getMonth()+1).toString().padStart(2,'0')
var d = nowdate.getDate().toString().padStart(2,'0')
var preMonth = y+'-'+m+'-'+d
that.date=preMonth
that.date2=preMonth
适用于时间戳转换日期的时候顺便补0
var change = new Date(that.dataList[i][0] * 1000)
var Y = change.getFullYear() + "-"
var M = (change.getMonth() + 1 <10 ? "0" + (change.getMonth() + 1) : change.getMonth() + 1) + "-"
var D= (change.getDate() <10 ? "0" + (change.getDate()) : change.getDate()) + " "
var h= (change.getHours() <10 ? "0" + (change.getHours()) : change.getHours()) + ":"
var m= (change.getMinutes() <10 ? "0" + (change.getMinutes()) : change.getMinutes()) + ":"
var s= (change.getSeconds() <10 ? "0" + (change.getSeconds()) : change.getSeconds())
var newDate = Y + M + D + h + m + s
1)在input失去焦点的func里面操作,2)检查文本的长度:
if 文本长度离目标长度相差n的话
then input的文本 = n*0 + 原文本
即可。