Template:Time Ago: Difference between revisions

From Zombie Panic! Official Wiki
Jump to navigation Jump to search
Created page with "<includeonly>{{#invoke:Time Ago|main}}</includeonly><noinclude>{{Documentation}}</noinclude>"
 
(No difference)

Latest revision as of 13:38, 10 June 2025

Documentation icon Template documentation
Note: parts of or the entire template might not be visible without values provided.
This template uses Module:Time Ago, a script written in Lua.

Get the time since or time until a date.

Syntax

If the time is lower than the last date unit specified, the next valid date unit will be shown instead.
{{Time Ago|date|last = last date unit to display|include = comma list of the date units to display|hidelabel = show number only and hide label text}}

  • Date units accepted:
    • y or year — display up to years
    • mth or month — display up to months
    • w or week — display up to weeks
    • d or day — display up to days
    • h or hour — display up to hours
    • min or minute — display up to minutes
    • blank — displays up to seconds
  • include — takes priority over last, enter a comma list of valid date units to display
  • last — defaults to blank.
  • lowercase — lowercase output.

Examples

Basic Function

{{Time Ago|2025-12-23|last = w}} yields: In 2 weeks
{{Time Ago|2025-12-23|last = y}} yields: In 2 weeks
{{Time Ago|2020-12-23|last = d}} yields: 4 years, 11 months, 2 weeks, 1 day ago
{{Time Ago|2019-12-23|last = month}} yields: 5 years, 11 months ago

Pick and Choose units

{{Time Ago|2019-12-23|include = y,mth,d}} yields: 5 years, 11 months, 16 days ago
{{Time Ago|2019-12-23|include = mth}} yields: 71 months ago
{{Time Ago|2022-08-22|include = y,mth,d}} yields: 3 years, 3 months, 17 days ago

No Labels

{{Time Ago|2020-09-28|hidelabel = 1}} yields: 5, 2, 1, 3, 11, 47, 20
{{Time Ago|2020-09-28|last = year|hidelabel = 1}} yields: 5

Lowercase

{{Time Ago|2050-09-28|last = y|lowercase = 1}} yields: in 24 years

Template Data

Get the time since or time until a date.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Date1

Datetime to display.

Daterequired
Last Unitlast

Smallest unit of time to display down to.

Example
"y", "mth", "w", "d", "h", "min", ""
Stringsuggested
Units to Includeinclude

Comma list of unit(s) of time to display.

Example
"y, mth, h", "w, min"
Stringsuggested
Hide Labelhidelabel

Set to "1" to remove "In", "ago", and time unit text.

Example
1
Booleanoptional
Lowercase Outputlowercase

Set to "1" to have lowercase "in".

Example
1
Booleanoptional