diff --git a/surfsense_web/lib/format-date.ts b/surfsense_web/lib/format-date.ts index c2f445537..a062b08fa 100644 --- a/surfsense_web/lib/format-date.ts +++ b/surfsense_web/lib/format-date.ts @@ -68,3 +68,17 @@ export function formatRelativeFutureDate(dateString: string): string { export function formatThreadTimestamp(dateString: string): string { return format(new Date(dateString), "MMM d, yyyy 'at' h:mm a"); } + +/** + * Format a chat message timestamp for inline display under a bubble. + * Locale-aware, 12-hour clock. Example: "Jul 13, 10:42 PM". + */ +export function formatMessageTimestamp(date: Date): string { + return date.toLocaleDateString(undefined, { + month: "short", + day: "numeric", + hour: "numeric", + minute: "2-digit", + hour12: true, + }); +}