Skip to content

useTimezone

Manage the chart timezone.

const { timezones, activeTimezone, setTimezone } = useTimezone();
FieldTypeDescription
timezonesTimezoneItem[]Full list of timezones
activeTimezonestringCurrent IANA timezone key
setTimezone(timezone: string) => voidChange the timezone
interface TimezoneItem {
key: string; // IANA: "Europe/London", "America/New_York", "UTC"
localeKey: string; // short name: "london", "new_york", "utc"
}

Available timezones: UTC, Pacific/Honolulu, America/Juneau, America/Los_Angeles, America/Chicago, America/Toronto, America/Sao_Paulo, Europe/London, Europe/Berlin, Asia/Bahrain, Asia/Dubai, Asia/Ashkhabad, Asia/Almaty, Asia/Bangkok, Asia/Shanghai, Asia/Tokyo, Australia/Sydney, Pacific/Norfolk.

const { timezones, activeTimezone, setTimezone } = useTimezone();
<select value={activeTimezone} onChange={(e) => setTimezone(e.target.value)}>
{timezones.map((tz) => (
<option key={tz.key} value={tz.key}>
{tz.key}
</option>
))}
</select>;