Skip to content

Commit 7830dc7

Browse files
committed
refactor: use datetimeformat
1 parent c9d92a5 commit 7830dc7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/logger/utils/time.mjs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
export const prettifyTimestamp = timestamp => {
1111
const date = new Date(timestamp);
1212

13-
const hours = date.getUTCHours().toString().padStart(2, '0');
14-
const minutes = date.getUTCMinutes().toString().padStart(2, '0');
15-
const seconds = date.getUTCSeconds().toString().padStart(2, '0');
16-
const milliseconds = date.getUTCMilliseconds().toString().padStart(3, '0');
17-
18-
return `${hours}:${minutes}:${seconds}.${milliseconds}`;
13+
return new Intl.DateTimeFormat('en-US', {
14+
timeZone: 'UTC',
15+
hour12: false,
16+
hour: '2-digit',
17+
minute: '2-digit',
18+
second: '2-digit',
19+
fractionalSecondDigits: 3,
20+
}).format(date);
1921
};

0 commit comments

Comments
 (0)