This commit is contained in:
Abin committed 2026-01-05 18:08:24 +08:00
1 parent c2f0c46c4d
commit ae460a571e
10 files changed
+270

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
const formatTime = timestamp => {
const date = new Date(timestamp);
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
module.exports = {
formatTime
}