Home
Random
Log in
Settings
About the Petit Planet Wiki
Search
Editing
Template
:
Time Ago/doc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{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 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 {{T|Time Ago|2025-12-23|p2=last=w|_Y_=1}}<br> {{T|Time Ago|2025-12-23|p2=last=y|_Y_=1}}<br> {{T|Time Ago|2020-12-23|p2=last=d|_Y_=1}}<br> {{T|Time Ago|2019-12-23|p2=last=month|_Y_=1}}<br> ;Pick and Choose units {{T|Time Ago|2019-12-23|p2=include=y,mth,d|_Y_=1}}<br> {{T|Time Ago|2019-12-23|p2=include=mth|_Y_=1}}<br> {{T|Time Ago|2022-08-22|p2=include=y,mth,d|_Y_=1}}<br> ;No Labels {{T|Time Ago|2020-09-28|p2=hidelabel=1|_Y_=1}}<br> {{T|Time Ago|2020-09-28|p2=last=year|p3=hidelabel=1|_Y_=1}} ;Lowercase {{T|Time Ago|2050-09-28|p2=last=y|p3=lowercase=1|_Y_=1}} ==Template Data== <templatedata> { "params": { "1": { "label": "Date", "description": "Datetime to display.", "type": "date", "required": true }, "last": { "label": "Last Unit", "description": "Smallest unit of time to display down to.", "example": "\"y\", \"mth\", \"w\", \"d\", \"h\", \"min\", \"\"", "type": "string", "suggested": true }, "include": { "label": "Units to Include", "description": "Comma list of unit(s) of time to display.", "example": "\"y, mth, h\", \"w, min\"", "type": "string", "suggested": true }, "hidelabel": { "label": "Hide Label", "description": "Set to \"1\" to remove \"In\", \"ago\", and time unit text.", "example": "1", "type": "boolean" }, "lowercase": { "label": "Lowercase Output", "description": "Set to \"1\" to have lowercase \"in\".", "example": "1", "type": "boolean" } }, "description": "Get the time since or time until a date.", "paramOrder": [ "1", "last", "include", "hidelabel", "lowercase" ], "format": "inline" } </templatedata>
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
Petit Planet Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Pages included on this page:
Template:Array
(
edit
)
Template:Documentation/Header
(
edit
)
Template:Documentation/styles.css
(
edit
)
Template:Lua
(
edit
)
Template:MessageBox
(
edit
)
Template:Namespace
(
edit
)
Template:T
(
edit
)
Template:Time Ago
(
edit
)
Module:Arguments
(
edit
)
Module:Arguments/i18n
(
edit
)
Module:Array
(
edit
)
Module:Common/i18n
(
edit
)
Module:Config
(
edit
)
Module:Documentation
(
edit
)
Module:Documentation/config
(
edit
)
Module:Documentation/i18n
(
edit
)
Module:Entrypoint
(
edit
)
Module:Exists
(
edit
)
Module:Fallbacklist
(
edit
)
Module:Feature
(
edit
)
Module:Formatting
(
edit
)
Module:I18n
(
edit
)
Module:Languages
(
edit
)
Module:Mbox
(
edit
)
Module:Mbox/i18n
(
edit
)
Module:Namespace detect
(
edit
)
Module:Namespace detect/config
(
edit
)
Module:Namespace detect/data
(
edit
)
Module:TableTools
(
edit
)
Module:Time Ago
(
edit
)
Module:Time Ago/i18n
(
edit
)
Module:Yesno
(
edit
)