#How can I set a value as the client's time zone in Qwik without using useVisbleTask$.

2 messages · Page 1 of 1 (latest)

valid tulip
#

How can I set a value as the client's time zone in Qwik without using useVisbleTask$.

I am trying to get the client's timezone, since everything is running in the serivdor I get the server's timezone, which is not the same as the client's.
Provisionally I have this solution, but Qwik in its documentation recommends not to use useVisibleTask$.

    const timezone = useSignal(Intl.DateTimeFormat().resolvedOptions().timeZone)
    const filtersMarkers = useStore<FiltersMarkerState>({
      selectDayStream: startOfToday(),
      status: undefined
    })

    useVisibleTask$(() => {
      timezone.value = Intl.DateTimeFormat().resolvedOptions().timeZone
      filtersMarkers.selectDayStream = utcToZonedTime(startOfToday(), timezone.value)
    })

Does anyone know a solution?

arctic forge