Template:Duration: Difference between revisions
Template page
More actions
m Remove some debugging text I accidentally left in |
reorder visual editor parameter order |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<includeonly>{{#invoke:Duration|fromSeconds | <includeonly>{{#invoke:Duration|fromSeconds}}</includeonly><noinclude><templatedata>{ | ||
"description": "Convert a duration to a human-readable format.", | |||
"params": { | |||
"Seconds": { | |||
"label": "Seconds", | |||
"type": "number", | |||
"required": false, | |||
"suggested": false, | |||
"description": "Seconds to add to the duration.", | |||
"aliases": [ | |||
1, | |||
"seconds" | |||
] | |||
}, | |||
"Minutes": { | |||
"label": "Minutes", | |||
"type": "number", | |||
"required": false, | |||
"suggested": false, | |||
"description": "Minutes to add to the duration.", | |||
"aliases": [ | |||
"minutes" | |||
] | |||
}, | |||
"Hours": { | |||
"label": "Hours", | |||
"type": "number", | |||
"required": false, | |||
"suggested": false, | |||
"description": "Hours to add to the duration.", | |||
"aliases": [ | |||
"hours" | |||
] | |||
}, | |||
"Days": { | |||
"label": "Days", | |||
"type": "number", | |||
"required": false, | |||
"suggested": false, | |||
"description": "Days to add to the duration.", | |||
"aliases": [ | |||
"days" | |||
] | |||
} | |||
}, | |||
"paramOrder": [ | |||
"Days", | |||
"Hours", | |||
"Minutes", | |||
"Seconds" | |||
] | |||
}</templatedata>{{Documentation}}</noinclude> | |||
Latest revision as of 05:18, 19 March 2026
Convert a duration to a human-readable format.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Days | Days days | Days to add to the duration. | Number | optional |
| Hours | Hours hours | Hours to add to the duration. | Number | optional |
| Minutes | Minutes minutes | Minutes to add to the duration. | Number | optional |
| Seconds | Seconds 1 seconds | Seconds to add to the duration. | Number | optional |
This template converts a duration in seconds to a human-readable format that is broken up into hours, minutes, and seconds.
Usage
Use the Seconds, Minutes, Hours and Days parameters to set the duration.
Examples
| Wikitext | Renders as |
|---|---|
{{Duration|seconds=4830}} |
1 h 20 min 30 s |
{{Duration|hours=2.5}} |
2 h 30 min |
{{Duration|seconds=7200}} |
2 h |
{{Duration|hours=2|seconds=30}} |
2 h 30 s |
{{Duration|seconds=333}} |
5 min 33 s |
{{Duration|seconds=120}} |
2 min |
{{Duration|seconds=42}} |
42 s |
| The above documentation is transcluded from Template:Duration/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |