Skip to content

Show chat message date and time in YYYY/MM/DD format#189

Merged
ht3aa merged 2 commits intomainfrom
cursor/2026-04-06-chat-message-datetime
Apr 6, 2026
Merged

Show chat message date and time in YYYY/MM/DD format#189
ht3aa merged 2 commits intomainfrom
cursor/2026-04-06-chat-message-datetime

Conversation

@ht3aa
Copy link
Copy Markdown
Owner

@ht3aa ht3aa commented Apr 6, 2026

Summary

  • Chat bubbles now display each message timestamp as YYYY/MM/DD plus the localized time (replacing time-only labels).
  • formatMessageDateTime in resources/js/composables/useChat.ts builds the date; MessageBubble.vue uses it next to the sender name.

Verification

  • npm run build (optional; run locally if you need a production asset refresh).

Made with Cursor

Replace time-only formatting with formatMessageDateTime so each bubble shows the calendar date (year/month/day) next to the localized time.

Made-with: Cursor
@ht3aa ht3aa added the cursor Pull request opened by a Cursor agent label Apr 6, 2026
@ht3aa ht3aa merged commit 456929f into main Apr 6, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the chat message timestamp display by renaming the utility function formatMessageTime to formatMessageDateTime and modifying it to include the date alongside the time. I have kept the feedback regarding the potential breaking change of renaming the utility and the suggestion to add input validation for the date string to prevent invalid output.


export function formatMessageTime(dateString: string): string {
return new Date(dateString).toLocaleTimeString(undefined, {
export function formatMessageDateTime(dateString: string): string {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Renaming formatMessageTime to formatMessageDateTime is a breaking change. If this utility is used in other parts of the application not included in this PR, those components will fail to import the function. Please verify that all occurrences have been updated or provide a backward-compatible alias.

Comment on lines +61 to 72
export function formatMessageDateTime(dateString: string): string {
const date = new Date(dateString);
const y = date.getFullYear();
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const time = date.toLocaleTimeString(undefined, {
hour: '2-digit',
minute: '2-digit',
});

return `${y}/${m}/${d} ${time}`;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The formatMessageDateTime function lacks validation for the input dateString. If an invalid or empty string is provided, new Date(dateString) will result in an Invalid Date, causing the function to return a string with NaN values (e.g., "NaN/NaN/NaN Invalid Date"). Adding a check for date validity ensures the UI remains clean even with unexpected data.

export function formatMessageDateTime(dateString: string): string {
    const date = new Date(dateString);
    if (isNaN(date.getTime())) {
        return '';
    }
    const y = date.getFullYear();
    const m = String(date.getMonth() + 1).padStart(2, '0');
    const d = String(date.getDate()).padStart(2, '0');
    const time = date.toLocaleTimeString(undefined, {
        hour: '2-digit',
        minute: '2-digit',
    });

    return `${y}/${m}/${d} ${time}`;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor Pull request opened by a Cursor agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant