Fix timezone issue: display booking slots in UTC
- Changed formatTime() to use UTC methods instead of toLocaleTimeString() - Prevents timezone conversion when displaying booking slots - Now admin sets 9-17 and user sees 9-17, regardless of timezone - Fixes 1-hour offset issue when user timezone differs from UTC
This commit is contained in:
parent
38b5f2a0a7
commit
7926e3ae4c
1 changed files with 6 additions and 6 deletions
|
|
@ -13,15 +13,15 @@ export function formatDate(d: Date): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format time from ISO string to HH:MM format.
|
* Format time from ISO string to HH:MM format in UTC.
|
||||||
|
* Uses UTC to avoid timezone conversion issues when displaying booking slots.
|
||||||
*/
|
*/
|
||||||
export function formatTime(isoString: string): string {
|
export function formatTime(isoString: string): string {
|
||||||
const d = new Date(isoString);
|
const d = new Date(isoString);
|
||||||
return d.toLocaleTimeString("en-US", {
|
// Use UTC methods to avoid timezone conversion
|
||||||
hour: "2-digit",
|
const hours = String(d.getUTCHours()).padStart(2, "0");
|
||||||
minute: "2-digit",
|
const minutes = String(d.getUTCMinutes()).padStart(2, "0");
|
||||||
hour12: false,
|
return `${hours}:${minutes}`;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue