//时间格式转化
formatDate(timeStamp) {
//时间戳转yyyy-mm-dd
if(timeStamp && timeStamp.search('-') === -1){
let time = new Date(Number(timeStamp)),
YY = time.getFullYear() + '-',
MM = (time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1) + '-',
DD = (time.getDate() < 10 ? '0' + (time.getDate()) : time.getDate()),
hh = (time.getHours() < 10 ? '0' + time.getHours() : time.getHours()) + ':',
mm = (time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes()) + ':',
ss = (time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds())
return YY + MM + DD +" "+hh + mm + ss;
//反转-传后端用
}else if(timeStamp && timeStamp.search('-') !== -1){
return new Date(timeStamp).getTime()
}else{
return ''
}
},
时间戳转换-前端处理时间戳函数vue
最新推荐文章于 2023-10-08 10:43:20 发布