Skip to content

Dates & Times

These guidelines summarize how to display time in a way that is clear, concise, and accessible.

Overview

All dates and times displayed should use the relative time component, which is able to format and localise dates into the users given locale, as well as display times relative to the current date, while also updating in real-time.

Dates and times almost always appear relative to the current date, using short-hand formats to help users quickly determine how old something is or how soon something will be. For this, we use the relative time component which displays dates rounded to the nearest unit, for example, "a minute ago" or "20 days ago". For dates that are more than 1 month from the current date, it can be more useful to display the date-time, as these items are less "current" and more "historical".

Some dates are especially sensitive and always should be displayed in a precise date-time format, such as the creation or expiration of certificates and keys. When a user needs to take action before a particular time (such as an expiry date) then the precise date time should be displayed. These should display the weekday, the date, the month, and the year (if the year is not the current year), for example, "Thursday, 26 August 2021" or "Saturday, 31 December 2022".

Some dates and times represent the start or (expected) end of an actively running task, for these the elapsed or remaining time should be displayed, as this information is more useful than when a task started. This format should display all units that are greater than zero, for example, "2 minutes, 24 seconds" or "8 hours, 15 seconds". For ephemeral tasks where timing needs to be quickly consumed, or where a lot of times may be displayed together, a compact time notation can be used, for example, "2m 24s" or "8h 15s".

Usage

Relative dates

Past dates

For past dates, the relative time component outputs different formats depending on the time difference. Within a month's time, the output shows a relative time1 in the format of X seconds/minutes/hours/days ago. If the time difference is less than 1 minute, it shows just now. If the date is in past months, the date time2 format on D MMM is used. If the date is in the past years, the format on D MMM, YYYY is used.

Time differenceFormatExamples
< 1 minutejust nowjust now
< 1 monthX seconds/minutes/hours/days agoa minute ago, 5 minutes ago, an hour ago, 3 hours ago, yesterday, 20 days ago
> 1 monthon D MMMon 18 Nov
Past yearon D MMM, YYYYon 26 Aug, 2021

Relative time examples

Future dates

Future dates also use different formats depending on the time difference. If the future date is due to happen within the a month's time, the relative time outputs the format of in X seconds/minutes/hours/days. If the time difference is less than 1 minute, it shows just now. If the date is in the following months, the format on D MMM is used. If the date is in the next year or further, the format on D MMM, YYYY is used.

Time differenceFormatExamples
< 1 minutejust nowjust now
< 1 monthin X seconds / minutes / hours / daysin a minute, in 2 minutes, in an hour, in 7 hours, tomorrow, in 14 days
> 1 monthon D MMMon 18 Nov
Next yearon D MMM, YYYYon 26 Aug, 2021

Standalone

The relative dates can be used within a sentence, following the action that it's relative to, or as an independent elements when the content and the surrounding elements make it clear what the time is related to.

Use standalone relative dates on items where its title references the action.

Use standalone relative dates a timeline item where the section title references the action.

The relative dates are used as plain text in most cases. However, they can be used to point to a list of historical changes, a timeline, or as an anchor link for nested information in a view. For example, a date could be used to link to a comment in a conversation thread.

A relative time as a link to a comment in a conversation.

Responsive design and micro format

Relative dates must remain readable and accessible in different screen sizes. We encourage to use long date formats (e.g. 2 months ago) instead of the micro format (e.g. 2mo) on mobile screens or narrow spaces, as it can be difficult for users to understand, it doesn't support browser translation, and causes issues with assistive technologies. For example, some screen readers, such as VoiceOver for mac, will read out 1m as 1 meter.

Do

Use readable, long date formats, and adapt the layout to the available space.

Don’t

Don't use narrow date formats, specially if there's a prominent space available or the layout can be adapted to the screen size.

Precise dates

For dates that needs to represent a precise date and time which the user should be aware of, dates should be displayed in a precise format that includes the weekday, date, month and if appropriate the hours minutes and seconds. This will take the format of weekday, MMM D, YYYY, HH:MM:SS [AP]M. The placement of these items may be different depending on locale.

Do

Use precise dates for future relevant dates.

Don’t

Don't use relative dates for future specific dates.

Do

Use precise dates when the user needs to know the exact time of past dates.

Don’t

Don't use relative dates for past specific dates.

Elapsed or remaining dates

For dates which represent the start or (expected) end of a currently running task or job, it is more useful to display the elapsed time since the task began, or remaining time until the task ends. This takes the long format of X years, X months, X days, X hours, X minutes, X seconds or the compact format of Xy Xm Xd Xh Xm Xs. Any 0 values will not be displayed. For some tasks where the expected end time is further away and second precision is not needed, it may be useful to display less precise data, such as down-to-the-day, taking the format of Xy Xm Xd.

PrecisionFormatExamples
secondXy Xm Xd Xh Xm Xs4s, 5m 32s, 1d 4h 32s
dayXy Xm Xd2y 3m, 2y 8m 5d, 2m 2d, 1y 4d

Use elapsed dates to represent the duration of a single or multiple running tasks.

Accessibility

A relative date is treated like a time element. It contains a title showing the precise localised date.


  1. Relative time data is derived from the Intl.RelativeTimeFormat API.
  2. Date time data is derived from the Intl.DateTimeFormat API.