Description:
There is a bug in how login times and session durations are being displayed. When a user logs in, the active sessions/login history UI shows the login time incorrectly (e.g., displaying "about 15 hours ago" or an incorrect AM/PM time for a login that just happened). This seems to be a timezone handling issue between the backend and frontend.
Current Behavior:
Immediately after a fresh login, the UI displays a drastically incorrect relative time instead of "Just now" or "0 minutes ago". (See attached screenshot).
Expected Behavior:
The frontend should correctly parse the timestamp sent by the backend, convert it to the user's local timezone, and display the accurate relative time (e.g., "Just now", "5 minutes ago").
Where to look / Possible Causes:
- Frontend: Check
frontend/src/components/ActiveSessionsList.tsx or similar components where the date formatting happens. Ensure we are correctly parsing UTC ISO strings before calculating the relative time.
- Backend: Check how timestamps are generated and serialized for
UserSession or LoginRecord in Django. Ensure timezone.now() is being used and serialized properly in ISO 8601 format with timezone awareness (Z or offset).
- Hint: We might need to use a library like
date-fns (e.g., formatDistanceToNow) on the frontend, ensuring the parsed date is timezone-aware.
Steps to Reproduce:
- Log into the application.
- Go to the dashboard or settings page where Active Sessions or Login History is displayed.
- Observe the "Last active" or login time for the current session.
Screenshots:

Description:
There is a bug in how login times and session durations are being displayed. When a user logs in, the active sessions/login history UI shows the login time incorrectly (e.g., displaying "about 15 hours ago" or an incorrect AM/PM time for a login that just happened). This seems to be a timezone handling issue between the backend and frontend.
Current Behavior:
Immediately after a fresh login, the UI displays a drastically incorrect relative time instead of "Just now" or "0 minutes ago". (See attached screenshot).
Expected Behavior:
The frontend should correctly parse the timestamp sent by the backend, convert it to the user's local timezone, and display the accurate relative time (e.g., "Just now", "5 minutes ago").
Where to look / Possible Causes:
frontend/src/components/ActiveSessionsList.tsxor similar components where the date formatting happens. Ensure we are correctly parsing UTC ISO strings before calculating the relative time.UserSessionorLoginRecordin Django. Ensuretimezone.now()is being used and serialized properly in ISO 8601 format with timezone awareness (Zor offset).date-fns(e.g.,formatDistanceToNow) on the frontend, ensuring the parsed date is timezone-aware.Steps to Reproduce:
Screenshots: