tiefen_space_h5/utils/tools.js

12 lines
565 B
JavaScript
Raw Normal View History

2024-07-02 23:08:38 +08:00
//格式化时间戳
export function formatDeadline(timestamp) {
const date = new Date(timestamp * 1000); // 时间戳以秒为单位需要乘以1000转换成毫秒
const year = date.getFullYear();
const month = ("0" + (date.getMonth() + 1)).slice(-2);
const day = ("0" + date.getDate()).slice(-2);
const hours = ("0" + date.getHours()).slice(-2);
const minutes = ("0" + date.getMinutes()).slice(-2);
const seconds = ("0" + date.getSeconds()).slice(-2);
return `${year}${month}${day}${hours}:${minutes}:${seconds}`;
}