// js中时间秒转为字符串yyyyMMddHHmmss
function format(timeStamp) {
//timeStamp,否则要parseInt转换
const time = new Date(timeStamp);
const y = time.getFullYear();
const m = time.getMonth() + 1;
const d = time.getDate();
const h = time.getHours();
const mm = time.getMinutes();
const s = time.getSeconds();
return (
y +
"-" +
this.add(m) +
"-" +
this.add(d) +
" " +
this.add(h) +
":" +
this.add(mm) +
":" +
this.add(s)
);
}
JavaScript中时间秒转为字符串yyyyMMddHHmmss
最新推荐文章于 2024-07-18 17:32:29 发布