/**
* 格式化时间
* 时间戳单位: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 timestamp to time (year, month, day)
Guess you like
Origin blog.csdn.net/xiaoxiannv666/article/details/118089318
Recommended
Ranking