Skip to content

Commit 4a49e6a

Browse files
author
reco_luan
committed
fix: fix date format is not correct
1 parent d6d8ce4 commit 4a49e6a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

components/PageInfo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080
return fromatDateTime(value)
8181
} else {
8282
// 用户没有输入或者输入了 00:00:00
83-
return new Date(value).toLocaleDateString()
83+
return fromatDateTime(value, 'date')
8484
}
8585
}
8686
},

util/formatDate.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*/
77

88
// 将时间格式化成 YYYY/MM/DD HH:mm:SS
9-
export const fromatDateTime = (time) => {
9+
export function fromatDateTime (time, type) {
10+
time = time.replace(/-/g, '/')
1011
const date = new Date(time)
1112
const Y = date.getFullYear()
1213
const M = date.getMonth() + 1
@@ -17,5 +18,6 @@ export const fromatDateTime = (time) => {
1718
m = m > 9 ? m : '0' + m
1819
let S = date.getSeconds()
1920
S = S > 9 ? S : '0' + S
20-
return Y + '/' + M + '/' + D + ' ' + H + ':' + m + ':' + S
21-
}
21+
const dt = type === 'date' ? Y + '/' + M + '/' + D : Y + '/' + M + '/' + D + ' ' + H + ':' + m + ':' + S
22+
return dt
23+
}

0 commit comments

Comments
 (0)