formatInterval - Render an interval as a string
The formatInterval
function is useful when you wish to render out an interval
as a string
and specify the time units which are displayed.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
interval | interval | true | The interval to format |
scale | timeunit | false | The largest timeunit of the interval to show. This does not cascade. For example, if we specify day in this field, it does not follow that the interval will display day , hour , minute , seconds etc. It will display the day but it may skip other units. Defaults to nano |
Example - Rendering a long interval out as seconds only.
We may wish to count in something other than the highest applicable time unit. For example, even though an interval is 5 minutes long, we may wish to render this as 300s
.
This can be done using the formatInterval
function with the scale
argument set to s
or seconds
.
seconds_elapsed
will render on the screen as 300s
.
Theme
Light