Link Search Menu Expand Document (external link)

Dates and time

Timestamps

Date+time is the most precise option, but can be difficult to intuitively reason about (given the odd math involved in dates and times). Use a timestamp:

  • When the user is likely to need to correlate the screen value with a timestamp in another system, such as a log
  • When showing a time range
  • When showing an event or job which is scheduled at an exact future time
  • When showing data from a table or third-party source

By default, just use toDateString() and/or toTimeString() (or the locale-specific versions). If we know the user is very likely to compare the date to values in another source, try to follow the conventions of that source.

Offset from Now

Offsets are easy to reason about but lack precision.

Octocat logo m-cloud-app (Github)

Use the following rubric when preparing an offset for display:

  • Calculate years, months, days, hour, minutes, seconds
  • Show the two most significant values. If there are less than two, show one.
  • If the offset was less than 30s ago, show “Just now” otherwise append “ ago” to the value

When showing an offset, offer a tooltip with the exact timestamp.


Copyright © 2022 FeatureBase, Inc.