sistema-de-chamados/src/hooks/use-local-time-zone.ts
2025-11-08 02:34:43 -03:00

19 lines
450 B
TypeScript

import { useEffect, useState } from "react"
export function useLocalTimeZone(fallback?: string) {
const [timeZone, setTimeZone] = useState<string | undefined>(fallback)
useEffect(() => {
if (typeof window === "undefined") return
try {
const resolved = Intl.DateTimeFormat().resolvedOptions().timeZone
if (resolved) {
setTimeZone(resolved)
}
} catch {
/* ignore */
}
}, [])
return timeZone
}