Template:Time Ago/doc

From Zombie Panic! Official Wiki
Revision as of 13:38, 10 June 2025 by Wuffesan (talk | contribs) (Created page with "{{Documentation/Header}} {{Lua|Time Ago}} 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.<br /> {{T|Time Ago|v1=date|v2=last=last date unit to display|v3=include=comma list of the date units to display|v4=hidelabel=show number only and hide label text}} * Date units accepted: ** ''y'' or ''year'' — display up to years ** ''mth'' or ''month'' — display...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This is the documentation page for Time Ago.
It contains usage information, categories, and other content not part of the original template page.
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, 9, 40
{{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