js/vue处理日期格式
switchTimeFormat (time) {const dateTime = new Date(time)const year = dateTime.getFullYear()const month = dateTime.getMonth() + 1const date = dateTime.getDate()const hour = dateTime.getHours()const min
·
switchTimeFormat (time) {
const dateTime = new Date(time)
const year = dateTime.getFullYear()
const month = dateTime.getMonth() + 1
const date = dateTime.getDate()
const hour = dateTime.getHours()
const minute = dateTime.getMinutes()
const second = dateTime.getSeconds()
return `${year}-${this.addZero(month)}-${this.addZero(date)} ${this.addZero(hour)}:${this.addZero(minute)}:${this.addZero(second)`
},
addZero (v) {
return v < 10 ? '0' + v : v
}
更多推荐
已为社区贡献4条内容
所有评论(0)