/**
* 格式化时间
* 时间戳单位:s
*/
secToTime(seconds) {
let date = new Date(seconds);
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
let minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
let second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
if (month < 10) month = '0' + month;
if (day < 10) day = '0' + day;
let currentTime = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
return currentTime;
},
js时间戳转时间(年月日)
最新推荐文章于 2024-06-14 13:05:32 发布