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

Script error: No such module "Time ago".

Template documentation (for the above template, sometimes hidden or invisible) [view] [edit] [history] [refresh]

Template:Documentation header Template:Lua Displays the relative time between a given date and the current time (e.g. "3 days ago", "2 months time").

Usage

Displays the amount of time elapsed between a supplied date/time and the present moment in a human-readable format.

Basic syntax

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Example

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Produces: Template:Time ago

Parameters

Required

Parameter Description
1 Date or timestamp to compare with the current time. Must be parseable by MediaWiki.

Optional

magnitude

Forces the output to use a specific unit instead of automatic selection.

Valid values:

  • seconds
  • minutes
  • hours
  • days
  • weeks
  • months
  • years

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Produces: Template:Time ago

min_magnitude

Specifies the smallest unit of time that may be displayed.

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

This prevents results such as "12 hours ago".

ago

Controls suffix text.

Value Result
(default) 3 days ago
ago= 3 days
ago=since 3 days since

spellout

Controls whether numbers are written as words.

Value Behavior
no Never spell numbers (default)
auto Spell numbers from 1–9
yes Spell numbers from 1–100

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Produces: Template:Time ago

spelloutmax

Sets an upper limit for spelled-out numbers.

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

In this case, the date is Template:Time ago. Because the amount of years is larger than 5, it doesn't spell it out.

purge

Adds a purge link to the output to allow manual cache refresh.

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Produces: Template:Time ago

Future dates

Dates in the future are supported automatically.

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Produces: Template:Time ago

If ago= is empty:

<syntaxhighlight lang="wikitext"> Template:Time ago </syntaxhighlight>

Produces: Template:Time ago

Accepted date formats

The first parameter accepts any date format supported by MediaWiki, including:

  • YYYY-MM-DD
  • YYYY-MM-DD HH:MM
  • Month D, YYYY
  • yesterday, today, now

Error handling

If the date cannot be parsed, the template displays:

Error: first parameter cannot be parsed as a date or time.

Unit selection

The template automatically selects a unit using the following thresholds:

Minimum elapsed time Unit used
≥ 2 years Years
≥ 2 months Months
≥ 2 days Days
≥ 2 hours Hours
≥ 2 minutes Minutes
Otherwise Seconds


nl:Sjabloon:Tijd geleden ru:Шаблон:Времени назад

th:แม่แบบ:Time ago
The above text is transcluded from Template:MC/Time ago/doc; you can change it or view its history.
If you're done making changes, please refresh the text.
Please add categories and interwikis to Template:MC/Time ago/doc. (View all subpages of this page.)