Displays a date/time formatted in one of a number of predefined formats.
The component can be imported via:
The component accepts the date to be formatted in the date prop. This can be a Date instance,
a valid time string (one that would be accepted by the Date constructor),
or a number - a unix timestamp (in milliseconds).
The component supports a few predefined formats, which can be selected with
the format prop on the component. The available options are:
Putting these together, the component would be invoked like:
Internally, the component uses Intl.RelativeTimeFormat
to create the formatted strings.
The component accepts a withRelativeDateFromNow prop (boolean), which - when enabled -
will make the component format the date component of the formatted string as Yesterday, Today,
or Tomorrow - if the date is yesterday, today or tomorrow relative to the current time.
When showing dates formatted in a shorter format, it may be helpful to show a tooltip with
the full version of the date.
The component supports a tooltip, which can be enabled with the withTooltip prop.
Additionally, isTooltipTriggerUnderlined may be set to true, to add an underlined style
to the formatted date, to better indicate that it's interactive:
When using the relative date format, the tooltip can be made "smart" and only render when "Yesterday", "Today", or "Tomorrow" is shown:
Internally, the component uses the formatDateTime utility, which can be imported as
The utility accepts three arguments:
date - the date to formatformat - (optional) the format to use for the output stringdateTimeFormatOptions - (optional) overrides to use for Intl.DateTimeFormat, which is used internally for formattingoptions - (optional) an object with the following properties:
withRelativeDateFromNow - controls whether close dates should show as "Yesterday"/"Today"/"Tomorrow"shouldUppercaseFirst - whether the first letter of the formatted string should be uppercasedPlumaFormattedDateTime extends TextThe Date to format. Can be a Date object, a number (representing a UNIX timestamp in seconds or milliseconds), or a valid date time string.
Numeric values below 10_000_000_000 are treated as epoch seconds and
automatically converted to milliseconds.
null, undefined, and 0 are treated as missing — the component
renders an em dash (—) fallback.
Any Intl.DateTimeFormat options
to pass into the formatter. This may override presets set by the format prop.
Default:'medium_with_time'
One of the predefined formats to use.
time: 8:12:34 AM (PST)medium: Jan 30, 2012medium_with_time: Jan 30, 2012, 8:12:34 AM (PST)full: Mon, Jan 30, 2012full_with_time: Mon, Jan 30, 2012, 8:12:34 am (PST)Note: modifying other format props may affect the final output.
When withTooltip is enabled, controls whether the tooltip trigger should
include an underlined style.
Whether the formatted string should start with an uppercase letter.
Set this to false when, for example, you need "today" instead
of "Today" for relative-formatted strings.
Note: This option has no effect on month or weekday names - they remain capitalized either way.
Whether the formatted string should use "Yesterday", "Today", and "Tomorrow"
instead of the formatted date (relative to today).
Only applies when medium, medium_with_time, full, or full_with_time formats are used.
Whether the component should display a tooltip with the full formatted date.
When withRelativeDateFromNow is enabled, enabling this
option will show a tooltip with the full date, but only
if the formatted date shows "Yesterday", "Today", or "Tomorrow".