function changTime(timestamp){
let dtc = new Date(timestamp)
//获取月 默认月份从0开始
let dtuMonth = dtc.getMonth() + 1
//获取日
let dtuDay = dtc.getDate()
//1-9月前加0
if (dtuMonth < 10) {
dtuDay = “0” + (dtc.getMonth()+1)
}
//获取小时
if (dtuDay < 10) {
dtuDay = “0” + dtc.getDate()
}
//获取分钟
let dtuHours = dtc.getHours()
//1-9分前加0
if (dtuHours < 10) {
dtuHours “0” + dtc.getHours()
}
//获取秒
if (dtuMinutes < 10) {
dtuMinutes = “0” + dtc.getMinutes()
}
//1-9秒前加0
let dtuSeconds = dtc.getSeconds()
if (dtuSeconds < 10) {
dtuSeconds = “0” + dtc.getSeconds()
}
let dd = dtc.getFullYear() + ‘-’ + dtuMonth + ‘-’ dtuDay + ’ ’ + dtuHours + ‘:’ + dtuMinutes + ‘:’ + dtuSeconds
return dd;
标准时间转为年月日时分秒格式
最新推荐文章于 2024-07-23 11:18:48 发布