// 获取当前时间并格式化
function getNowFormatDate(){
const time = new Date()
let y = time.getFullYear()
let m = time.getMonth()+1
let d = time.getDate()
let h = time.getHours()
let mi = time.getMinutes()
let s = time.getSeconds()
m = m<10?`0${m}`:m
d = d<10?`0${d}`:d
h = h<10?`0${h}`:h
mi = mi<10?`0${mi}`:mi
s = s<10?`0${s}`:s
let ddd = `${y}-${m}-${d} ${h}:${mi}:${s}`
console.log(ddd); // 2020-07-28 13:56:38
return ddd
}
时间格式化
最新推荐文章于 2023-01-11 14:31:23 发布