JS 10位、13位时间戳转日期
2021-01-21 19:13
标签:mon nbsp cond 判断 注意 date 函数 gets res (注意:下面的date可以加个判断是10位时间戳还是13位时间戳来进行编码是否需要*1000; param为你要转换的时间戳变量 let date = new Date(parseInt(res.data.rows[i].time) * 1000); JS 10位、13位时间戳转日期 标签:mon nbsp cond 判断 注意 date 函数 gets res 原文地址:https://www.cnblogs.com/haimeimei/p/13292127.html
if(param.length == 10){
let date = new Date(parseInt(param) * 1000);
}else if(param.length == 13){
let date = new Date(parseInt(param));
}
)
let y = date.getFullYear();
let m = date.getMonth() + 1;
m = m let d = date.getDate();
d = d let h = date.getHours();
h = h let minute = date.getMinutes();
let second = date.getSeconds();
minute = minute // console.log( y + ‘-‘ + m + ‘-‘ + d + ‘ ‘ + ‘ ‘ + h + ‘:‘ + minute + ‘:‘ + second)
let dates = y + ‘-‘ + m + ‘-‘ + d + ‘ ‘ + ‘ ‘ + h + ‘:‘ + minute + ‘:‘ + second;// 封装的时间戳转换日期函数
dateTrans(date) {
let _date = new Date(parseInt(date));
let y = _date.getFullYear();
let m = _date.getMonth() + 1;
m = m let d = _date.getDate();
d = d let h = _date.getHours();
h = h let minute = _date.getMinutes();
let second = _date.getSeconds();
minute = minute // console.log( y + ‘-‘ + m + ‘-‘ + d + ‘ ‘ + ‘ ‘ + h + ‘:‘ + minute + ‘:‘ + second)
let dates = y + ‘-‘ + m + ‘-‘ + d;
return dates;
},
上一篇:CSS 08 字体