Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Duration: Difference between revisions

Template page
Tyraeis (talk | contribs)
Fix extra line breaks being included at the end of the template
RA2lover (talk | contribs)
reorder visual editor parameter order
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{#if: {{{seconds}}} |<!--
<includeonly>{{#invoke:Duration|fromSeconds}}</includeonly><noinclude><templatedata>{
-->{{#ifexpr: {{{seconds}}} > 3600 | {{#expr: trunc ({{{seconds}}} / 3600)}}&nbsp;h&nbsp;}}<!--
"description": "Convert a duration to a human-readable format.",
-->{{#ifexpr: {{{seconds}}} mod 3600 > 60 | {{#expr: trunc (({{{seconds}}}-(trunc ({{{seconds}}} / 3600))*3600) / 60)}}&nbsp;min&nbsp;}}<!--
"params": {
-->{{#ifexpr: {{{seconds}}} mod 60 > 0 or {{{seconds}}} = 0 | {{#expr: {{{seconds}}}-(trunc ({{{seconds}}} / 60))*60 }}&nbsp;s}}<!--
"Seconds": {
-->}}</includeonly><noinclude>{{Documentation}}</noinclude>
"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.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
DaysDays days

Days to add to the duration.

Numberoptional
HoursHours hours

Hours to add to the duration.

Numberoptional
MinutesMinutes minutes

Minutes to add to the duration.

Numberoptional
SecondsSeconds 1 seconds

Seconds to add to the duration.

Numberoptional
Template documentation[view] [edit] [history] [purge]

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