//时间转换
getDate(date){
const dd = new Date(date)
const y = dd.getFullYear()
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours() //获取当前小时,小于10补0
const mi = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes() //获取当前分钟数,不足10补0
const ss = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds() //获取当前秒数,不足10补0
return {
fullDate: y + '-' + m + '-' + d + ' ' + h + ':' + mi + ':' + ss,
year: y,
month: m,
date: d,
hour: h,
minutes: mi,
day: dd.getDay()
}
}
JS 中国标准时间转换yy-mm-dd HH:mm:ss
最新推荐文章于 2023-07-14 07:58:56 发布