The FormatDuration()
function converts a duration to text
Syntax
FormatDuration(duration, format)
FormatDuration(duration, language)
Returns
A new text string that is the text representation of a duration.
Parameters
-
duration
– a duration, in minutes, hours or seconds -
language
– this parameter is used to specify the time representation of that language. If thelanguage
parameter contains an unknown value, then the default portal language is used to format the duration. -
format
– the format is used to specify how the duration should be represented Theformat
parameter can contain a number of WEM specific options:- days – returns the total number of days in the
duration
- hours- returns the total number of hours in the
duration
- minutes – returns the total number of minutes in the
duration
- seconds – returns the total number of seconds in the
duration
- long – returns the duration as a written string, based on the portal language
- stopwatch – returns the duration formatted as follows:
(hours):(minutes):(seconds)
- clock – returns the duration formatted as follows:
(hours):(minutes)
You can also use the Microsoft format strings to format the duration.
- days – returns the total number of days in the
Examples
FormatDuration('3d4h17m30s', "hh")
/* returns "04" */
FormatDuration('3d4h17m30s', "d\\.h\\:mm\\:ss")
/* returns "3.4:17:30" */
FormatDuration('3d4h17m30s', "days")
/* returns "3" */
FormatDuration('3d4h17m30s', "hours")
/* returns "76" the returned string contains the total number of hours */
FormatDuration('3d4h17m30s', "long")
/* returns "3 days, 4 hours, 17 minutes and 30 seconds" */
FormatDuration('3d4h17m30s', "time")
/* returns "3" */
FormatDuration('3d4h17m30s', "en_US")
/* returns "3:4:17:30" */