diff --git a/frontend/app/utils/date.ts b/frontend/app/utils/date.ts index 56ebc06..2e34103 100644 --- a/frontend/app/utils/date.ts +++ b/frontend/app/utils/date.ts @@ -25,18 +25,23 @@ export function formatTime(isoString: string): string { } /** - * Format datetime from ISO string to a readable format. + * Format datetime from ISO string to a readable format in UTC. + * Uses UTC to avoid timezone conversion issues when displaying appointment times. */ export function formatDateTime(isoString: string): string { const d = new Date(isoString); - return d.toLocaleString("en-US", { - weekday: "short", - month: "short", - day: "numeric", - hour: "2-digit", - minute: "2-digit", - hour12: false, - }); + + // Use UTC methods to avoid timezone conversion + const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + + const weekday = weekdays[d.getUTCDay()]; + const month = months[d.getUTCMonth()]; + const day = d.getUTCDate(); + const hours = String(d.getUTCHours()).padStart(2, "0"); + const minutes = String(d.getUTCMinutes()).padStart(2, "0"); + + return `${weekday}, ${month} ${day}, ${hours}:${minutes}`; } /**