#Time zones in Phoenix

1 messages ยท Page 1 of 1 (latest)

coarse heath
#

What's the idiomatic way of using timezones in a Phoenix Liveview application?
In SvelteKit I work in UTC on the backend, and then just do a quick conversion in the frontend with a helper util that I call whenever displaying the date to the user.

I am not sure how to do it in Phoenix without it feeling over complicated with hooks.

trim rose
#

always use utc in the back no matter what framework you are using. Adjust to localize only on the client side because its completely subjective.
Even the same user could be using the same app in multiple TZs so don't even lock it to the user.

Its trivial to see the clients tz and render at the surface with the respective tz than it is to deal with tz at the inner most layers.

https://fly.io/phoenix-files/dates-formatting-with-hooks/

Fly

Converting datetimes from UTC format to the user's local timezone with Hooks

coarse heath
#

Awesome, thanks for the link, I'll try that setup

pseudo scaffold
void ether
#

This post keeps making me double take... I live in Arizona, so my timezone literally is "America/Phoenix" ๐Ÿ˜›

#

So the answer to the title of the post is "America/Phoenix" or "US/Arizona" if that doesn't work, or "MST" with daylight savings time turned off if that still doesn't work.

#

๐Ÿ˜›

quick lintel
#

But then you have to account for whether you're inside the Navajo reservation -- and if so, then also whether you're inside the Hopi res inside that. It's a recursive mess.

void ether
#

True, there are multiple time zones in my state, and my phone often has no idea what time it is. And twice I year I have to adjust to everyone else mucking with their time. Would love to see DST go away.