Skip to content

Commit 175b87c

Browse files
fix: getTimeFromTimestamp() incorrect padding for days (#2029)
use a simpler function to return localeString() instead.
1 parent 5fff9eb commit 175b87c

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

portal-ui/src/common/utils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -557,22 +557,13 @@ export const getTimeFromTimestamp = (
557557
fullDate: boolean = false
558558
) => {
559559
const timestampToInt = parseInt(timestamp);
560-
561560
if (isNaN(timestampToInt)) {
562561
return "";
563562
}
564563
const dateObject = new Date(timestampToInt * 1000);
565564

566565
if (fullDate) {
567-
return `${dateObject.getFullYear()}-${String(
568-
dateObject.getMonth() + 1
569-
).padStart(2, "0")}-${String(dateObject.getDay()).padStart(
570-
2,
571-
"0"
572-
)} ${dateObject.getHours()}:${String(dateObject.getMinutes()).padStart(
573-
2,
574-
"0"
575-
)}:${String(dateObject.getSeconds()).padStart(2, "0")}`;
566+
return dateObject.toLocaleString();
576567
}
577568
return `${dateObject.getHours()}:${String(dateObject.getMinutes()).padStart(
578569
2,

0 commit comments

Comments
 (0)