时间戳转化为时间时间格式

171 阅读1分钟
const date = new Date(time * 1000)//time 为10位的,13位不必乘 `1000`
const Y = date.getFullYear()
const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate())
const H = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
const Min = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
const dateTime = Y + '/' + M + '/' + D + ' ' + H + ':' + Min