Skip to content

Commit f4f8e3a

Browse files
Bugfix/time (#72)
* fix:time --------- Co-authored-by: cunyue-4060 <[email protected]>
1 parent 7440285 commit f4f8e3a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

vue/src/utils/time.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,25 @@ export const formatTime = (time) => {
7878
const localTime = date.getTime() - timezoneOffset * 60 * 1000
7979
const localDate = new Date(localTime)
8080
const year = localDate.getFullYear()
81-
const month = localDate.getMonth() + 1
82-
const day = localDate.getDate()
83-
const hour = localDate.getHours()
81+
let month = localDate.getMonth() + 1
82+
let day = localDate.getDate()
83+
let hour = localDate.getHours()
8484
let minute = localDate.getMinutes()
85-
const second = localDate.getSeconds()
85+
let second = localDate.getSeconds()
86+
/**
87+
* TO Little SHI:
88+
* 你需要在这解决时间的bug
89+
*/
8690
// 如果minute是个位数,转换成两位数
87-
if (minute < 10) {
88-
minute = '0' + minute
89-
}
91+
if (month < 10) month = '0' + month
92+
93+
if (day < 10) day = '0' + day
94+
95+
if (hour < 10) hour = '0' + hour
96+
97+
if (minute < 10) minute = '0' + minute
98+
99+
if (second < 10) second = '0' + second
100+
90101
return `${year}/${month}/${day} ${hour}:${minute}:${second}`
91102
}

0 commit comments

Comments
 (0)