Format a duration into a human readable string.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
as | string | optional[a] | The output name of the field to set (defaults to the same as the input field). | |
field [b] | string | required | The name of the input field. Must be an integer. | |
from | long | optional[a] | ms | Magnitude of the input field. |
Valid Values | ||||
d | Days | |||
h | Hours | |||
m | Minutes | |||
ms | Milliseconds | |||
ns | Nanoseconds | |||
s | Seconds | |||
us | Microseconds | |||
precision | number | optional[a] | 0 | Number of units to use in the output. |
[a] Optional parameters use their default value unless explicitly set. |
Formats a duration into a string. For example, an input event
with the field duration with the value
23452553
with a default
intepretation of the source value as milliseconds results in the
field duration having the value
6h30m52s553ms
.
formatDuration(duration)
Important
The value of the field being formatted should be an integer.
If you have a floating point input value, the value will not
be converted. To fix, use round()
or
format()
to create an integer value.
formatDuration()
Examples
Formats a duration into a string with limited precision. An
input event with the field duration with the value
23452553
results in the field
duration having the value
6h30m52s
.
formatDuration(duration, precision=3)