formatToParts

Returns an array of objects representing the relative time format in parts that can be used for custom locale-aware formatting.

Parameters

value
  • Numeric value to use in the internationalized relative time message

unit
  • Unit to use in the relative time internationalized message.

Throws

RangeError if unit was given something other than unit possible values

MDN.