Overview
Formatting options can be passed as the second parameter to thems() function:
Available options
extends
Extends a preset with additional options. This allows you to start with a preset and override specific settings.
hideUnitNames
Hide unit names from the output. Used as part of the
colonNotation preset.useAbbreviations
Use abbreviations for unit names instead of full names.
includeZero
Include units with the value 0 in the output. Used as part of the
colonNotation preset.includeMs
Include milliseconds in the output. Shorthand for adding
millisecond to the includedUnits option.includeSubMs
Include sub-millisecond units (microseconds and nanoseconds) in the output. Enabling this option automatically enables the
includeMs option. Shorthand for adding microsecond and nanosecond to the includedUnits option.Setting
includeSubMs: true while includeMs: false will throw an error due to conflicting options.includedUnits
Specify which units should be included in the output. Available units:
year, day, hour, minute, second, millisecond, microsecond, nanosecond.Use
includeMs and includeSubMs as convenient shortcuts instead of manually adding millisecond units to this array.unitLimit
The maximum number of units to include in the output. If the value is
-1, all units will be included.unitSeparator
The separator to use between units.
minimumDigits
The minimum number of digits for a unit value, padding with zeroes if needed. Used as part of the
colonNotation preset.Combining options
You can combine multiple options to achieve the exact formatting you need:Using with presets
You can extend presets with custom options:Type information
All formatting options are defined in theFormatOptions interface located in src/format/helpers/resolve-options.ts:5.