Skip to content

fix: show full date in formatTimestamp for non-today timestamps#1314

Open
yash113gadia wants to merge 1 commit into
RocketChat:developfrom
yash113gadia:fix/1313-last-login-full-date
Open

fix: show full date in formatTimestamp for non-today timestamps#1314
yash113gadia wants to merge 1 commit into
RocketChat:developfrom
yash113gadia:fix/1313-last-login-full-date

Conversation

@yash113gadia
Copy link
Copy Markdown

Show a full date for non-today timestamps in formatTimestamp

Acceptance Criteria fulfillment

  • Timestamps from a previous day show an unambiguous date with year
  • Same-day timestamps still render as time-only
  • Output is consistent with the adjacent createdAt field and message dates

Fixes #1313

Description

formatTimestamp (packages/react/src/lib/formatTimestamp.js) rendered any timestamp not from the current day as just a weekday + time:

return isDifferentDay
  ? `${date.toLocaleDateString('en-US', { weekday: 'long' })} ${formattedTime}`
  : formattedTime;

Since isDifferentDay only means "not today", every past timestamp collapsed to a bare weekday. In the Last login field of the User Information panel this is ambiguous — a login from months (or over a year) ago is indistinguishable from a recent one, and no year is ever shown.

The fix returns time-only for same-day timestamps (unchanged) and a full date with year otherwise.

Before / After

timestamp before after
90 days ago Tuesday 10:49 PM Mar 3, 2026, 10:49 PM
400 days ago Sunday 10:49 PM Apr 27, 2025, 10:49 PM
today 10:49 PM 10:49 PM

This matches how the adjacent created at field (formatTimestampGetDate) and message dates (date-fns) are already formatted.

PR Test Details

Open a User Information panel for a user whose last login was on a previous day → Last login now shows a dated, unambiguous value instead of a bare weekday. eslint passes clean on the changed file.

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 RocketChat#1313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: "Last login" shows ambiguous weekday with no date for logins older than today

1 participant