Connection lost
Reconnecting. If you just saved something, check that it saved before trying again.
Server error
Reconnecting to the server. If you just saved something, check that it saved before trying again.
Showing relative time in HEEX using Timex
0 comments
Here’s how to show when a record was created relative to the current time, e.g. “3 minutes ago”.
Add the Timex dependency ({:timex, "~> 3.7"}) to your mix.exs file, then use it:
def created_at(assigns) do
~H"""
<time datetime={Timex.format!(@created_at, "{ISO:Extended:Z}")}>
<%= Timex.format!(@created_at, "{relative}", :relative) %>
</time>
"""
end
and the result will look like this:
<time datetime="2024-12-18T11:01:00Z">4 minutes ago</time>