Skip to content

Commit fe99dc6

Browse files
committed
fix: local time in table cells
1 parent ccfee3e commit fe99dc6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

frontend/src/components/Timestamp.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ const Timestamp = ({ timestamp, mode, ...props }) => {
1919
if (!timestamp) return <></>;
2020
const localDateTime = new Date(timestamp * 1000);
2121

22-
const dateStr = localDateTime.toISOString().split('T')[0];
23-
const timeStr = localDateTime.toISOString().split('T')[1].split('.')[0];
22+
const yy = localDateTime.getFullYear();
23+
const mm = localDateTime.getMonth() + 1; // Months are zero-based
24+
const dd = localDateTime.getDate();
25+
26+
const hh = localDateTime.getHours();
27+
const min = localDateTime.getMinutes();
28+
const ss = localDateTime.getSeconds();
29+
30+
const pad = (n) => String(n).padStart(2, '0');
31+
const dateStr = `${yy}-${pad(mm)}-${pad(dd)}`;
32+
const timeStr = `${hh}:${pad(min)}:${pad(ss)}`;
2433

2534
return (
2635
<TimestampWrapper {...props}>

0 commit comments

Comments
 (0)