Skip to content

Commit 7e7301f

Browse files
时间格式更美观
1 parent 5f68854 commit 7e7301f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/lib/DateUtils.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,18 @@ export function dateStringUTC(date) {
129129
}
130130

131131
export function dateStringLocale(date) {
132-
let full = String(date.getDate()) + ' ' +
133-
shortMonth(date.getMonth()) + ' ' +
134-
String(date.getFullYear()) + ' at ';
132+
let month=date.getMonth()+1
133+
let date2=date.getDate()
134+
if(month<10){
135+
month = "0" + month;
136+
}
137+
if(date2<10){
138+
date2 = "0" + date2;
139+
}
140+
// let full = String(date.getDate()) + ' ' +
141+
// shortMonth(date.getMonth()) + ' ' +
142+
// String(date.getFullYear()) + ' at ';
143+
let full=String(String(date.getFullYear()+'-'+month+'-'+date2 +' '))
135144
let time = {
136145
hours: String(date.getHours()),
137146
minutes: String(date.getMinutes()),

0 commit comments

Comments
 (0)