js 中国标准时间转时分秒
程序员文章站
2022-03-30 09:03:38
...
function dateFormat(date) {
//日期格式化
var d = new Date(date)
let year = d.getFullYear()
let month = d.getMonth() + 1
month = '0' + month
month = month.substring(month.length - 2)
let day = '0' + d.getDate()
day = day.substring(day.length - 2)
let hour = '0' + d.getHours()
hour = hour.substring(hour.length - 2)
let m = '0' + d.getMinutes()
m = m.substring(m.length - 2)
let s = '0' + d.getSeconds()
s = s.substring(s.length - 2)
let format = year + '-' + month + '-' + day + ' ' + hour + ':' + m + ':' + s
return format
}
下一篇: Activity之间传递数据