优化
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
function TimeFormatting(timestamp) {
|
||||
const date = new Date(timestamp * 1000); // 秒级转毫秒级
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hour = String(date.getHours()).padStart(2, '0');
|
||||
const minute = String(date.getMinutes()).padStart(2, '0');
|
||||
const second = String(date.getSeconds()).padStart(2, '0');
|
||||
|
||||
return `${month}-${day} ${hour}:${minute}`;
|
||||
}
|
||||
export default TimeFormatting;
|
||||
const date = new Date(timestamp); // 直接使用毫秒级时间戳
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hour = String(date.getHours()).padStart(2, '0');
|
||||
const minute = String(date.getMinutes()).padStart(2, '0');
|
||||
const second = String(date.getSeconds()).padStart(2, '0');
|
||||
|
||||
return `${month}-${day} ${hour}:${minute}`;
|
||||
}
|
||||
export default TimeFormatting;
|
||||
|
||||
Reference in New Issue
Block a user