export function TimeChange(params){ let time; if(params.length>10){ // 当时间戳为13位的时候 time=new Date(params) }else{ time=new Date(params*1000) // 时间戳为10位的时候,先补充三位在进行转换 } let year=time.getFullYear()+'-'; let month=(time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1) + '-'; let day=(time.getDate()<10?'0'+time.getDate():time.getDate())+' '; let hour=(time.getHours()<10?'0'+time.getHours():time.getHours())+':'; let minute=(time.getMinutes()<10?'0'+time.getMinutes():time.getMinutes())+':'; let second=time.getSeconds()<10?'0'+time.getSeconds():time.getSeconds(); return year+month+day+hour+minute+second}
结果: