Time
A short relative time, as X shows it, with the full date on hover.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<% now = Time.utc(2026, 11, 4, 12) %>
<%= lc_stack gap: :related, as: :ul, class: "m-0 list-none p-0 text-small" do %>
<li>Posted <%= lc_time now - 30.seconds, now: now %></li>
<li>Posted <%= lc_time now - 12.minutes, now: now %></li>
<li>Posted <%= lc_time now - 4.hours, now: now %></li>
<li>Posted <%= lc_time Time.utc(2026, 10, 28, 9, 30), now: now %></li>
<li>Posted <%= lc_time Time.utc(2025, 11, 4, 18), now: now, detail: "edited" %></li>
<% end %>
Examples
Relative and dated
<% now = Time.utc(2026, 11, 4, 12) %>
<%= lc_stack gap: :related, as: :ul, class: "m-0 list-none p-0 text-small" do %>
<li>Posted <%= lc_time now - 30.seconds, now: now %></li>
<li>Posted <%= lc_time now - 12.minutes, now: now %></li>
<li>Posted <%= lc_time now - 4.hours, now: now %></li>
<li>Posted <%= lc_time Time.utc(2026, 10, 28, 9, 30), now: now %></li>
<li>Posted <%= lc_time Time.utc(2025, 11, 4, 18), now: now, detail: "edited" %></li>
<% end %>
API reference
Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.
lc_time
lc_time(time, now: Time.current, detail: nil, **attributes)
| Input | Default | Values |
|---|---|---|
| time | Required | — |
| now | Time.current | — |
| detail | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
The examples also use lc_stack. Each is documented on its own page.
Styling and extension
Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.