We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
![](https://assets.dockyard.com/dockyard_com/getting-and-displaying-the-users-local-time-in-liveview-4819fc48-cc72-4913-9b26-00f826ef88fa-og.png)
In a Phoenix/LiveView application, it’s a bit of a challenge to display the current time to the user in the user’s time zone. There are two primary reasons for this:
- Elixir code runs server-side rather than client-side, so the current time in our app’s Elixir code is the time on the server where our app is running.
- By default, Elixir can only handle the Coordinated Universal Time (UTC) time zone.
However, with a time zone library and a little JavaScript, we can solve both problems.
Let’s start by making a Phoenix application with a LiveView implementation of a clock.
continue reading on dockyard.com
⚠️ This post links to an external website. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.