blob: dbadbb810fdcf53e3c4d79a476fef9d8067d2167 [file] [log] [blame]
binquan.qiu7f2665f2020-03-27 17:19:57 +08001const formatTime = date => {
2 const year = date.getFullYear()
3 const month = date.getMonth() + 1
4 const day = date.getDate()
5 const hour = date.getHours()
6 const minute = date.getMinutes()
7 const second = date.getSeconds()
8
9 return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
10}
11
12const formatNumber = n => {
13 n = n.toString()
14 return n[1] ? n : '0' + n
15}
16
17module.exports = {
18 formatTime: formatTime
19}