Time

Relative and absolute times that stay correct without JavaScript and in one shown zone.

Absolute times show in the place's zone (here Asia/Kolkata ) on a 24-hour clock. When your browser's zone shows a different wall time, a hint with your own time is added. Nothing is converted silently.

Relative time

relative_time renders final English words inside <time datetime title> and refreshes them from one shared timer on the page. The title holds the exact time.

Relative time
  • Joined:
  • Edited:
  • Posted:
  • Replied:
  • Due:

Short and long

length is :long (default) or :short for tight places such as table cells.

Length
  • Long:
  • Short:
  • Short, future:

Local time

local_time shows an instant in the place's zone. The format is one of :date , :short , :long , :day , :time , :date_time , :day_time , :full or :month .

Formats
:date
:short
:long
:day
:time
:date_time
:day_time
:full
:month

The viewer's zone

The place's zone is Asia/Kolkata . If your browser is set to another zone, the line below gains a hint such as · Thu 04:30 your time . In India you see no hint, because both clocks agree.

Place zone and your zone

Class starts

Same instant in New York:

Hint switched off:

Setup

Converting to a named zone needs a time zone database. Sutra UI does not bundle one: add tz and configure it once.

# mix.exs
{:tz, "~> 0.28"}

# config/config.exs
config :elixir, :time_zone_database, Tz.TimeZoneDatabase

Notes

  • The server renders the words, so tests, emails and first paint are right without JavaScript.
  • Relative words refresh every 30 seconds while any is under an hour, then every five minutes.
  • A Date given a time format reads as its day; a NaiveDateTime has no zone, so its zone words are left out.

Are you sure?