Skip to content

Commit bba5007

Browse files
committed
fix: show full date in formatTimestamp for non-today timestamps
formatTimestamp rendered any timestamp that wasn't from the current day as a bare weekday + time (e.g. "Tuesday 10:49 PM"). This made the "Last login" field in the User Information panel ambiguous: a login from months — or even over a year — ago was indistinguishable from a recent one, and no year was ever shown. Now non-today timestamps include a full date with year (e.g. "Mar 3, 2026, 10:49 PM"), consistent with how createdAt (formatTimestampGetDate) and message dates (date-fns) are already shown. Same-day timestamps still render as time-only. Closes #1313
1 parent 8116b22 commit bba5007

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/react/src/lib/formatTimestamp.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ const formatTimestamp = (timestamp) => {
1010
const options = { hour: 'numeric', minute: 'numeric', hour12: true };
1111
const formattedTime = date.toLocaleTimeString('en-US', options);
1212

13-
return isDifferentDay
14-
? `${date.toLocaleDateString('en-US', {
15-
weekday: 'long',
16-
})} ${formattedTime}`
17-
: formattedTime;
13+
if (!isDifferentDay) {
14+
return formattedTime;
15+
}
16+
17+
const formattedDate = date.toLocaleDateString('en-US', {
18+
year: 'numeric',
19+
month: 'short',
20+
day: 'numeric',
21+
});
22+
23+
return `${formattedDate}, ${formattedTime}`;
1824
};
1925

2026
export default formatTimestamp;

0 commit comments

Comments
 (0)