Editing
Template:Time interval/doc
Jump to navigation
Jump to search
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 subpage}} {{Lua|Module:Age|Module:Date}} This template calculates the date/time difference between two dates. Dates in the [[Gregorian calendar]] from 9999 BCE to 9999 CE are supported. The calendar is proleptic—it is assumed to apply at all times with no irregularities. == Syntax == {{Template shortcuts|t-int}} *<code>{{time interval|''date1''|''date2''|''options''}}</code> There are two positional arguments: ''date1'' and ''date2''. The default for each is the current date and time. The result displays text representing the time interval from ''date1'' to ''date2'' (''date2'' − ''date1''). Dates are [[Coordinated Universal Time|UTC]]—local times and time zones are not supported. Dates are checked for validity. For example, 29 February 2000 is accepted, but 29 February 1900 is not a valid date. Each date can include an era or a time, and a variety of formats are accepted. Examples of valid dates are: :1900-02-01 :1900-2-1 :1900-02-01 14:45 :1 FEB 1900 :February 1, 1900 :February 1 1900 14:45 :2:45 pm February 1 1900 :1 February 1900 2:45 p.m. :BC 1 Feb 120 Examples: *<code><nowiki>{{time interval|1 Jan 2001|March 4, 2002}}</nowiki></code> → {{time interval|1 Jan 2001|March 4, 2002}} *<code><nowiki>{{time interval|1 Jan 2001|March 4, 2002|abbr=on}}</nowiki></code> → {{time interval|1 Jan 2001|March 4, 2002|abbr=on}} *<code><nowiki>{{time interval|B.C.E. 1 Feb 120|28 FEB 1900}}</nowiki></code> → {{time interval|B.C.E. 1 Feb 120|28 FEB 1900}} == Parameters == {| class="wikitable" ! Parameter !! Description |- | <code>abbr=off</code> || Unit names in full (default): year, month, day, hour, minute. |- | <code>abbr=on</code> || Units shown as a single letter with no space between number and unit: y, m, d, h, m. |- | <code>disp=age</code> || If no <code>show</code> has been entered, years are displayed if the age is above 3 years, years and months from 1 to 3 years, or months and days for under 1 year. Sets <code>sep=space</code> by default. This is compatible with {{tl|age for infant}}. |- | <code>disp=raw</code> || Display numbers only with <code>sep=space</code>. |- | <code>duration=on</code> || Period is a duration (has an extra day to include the end date). |- | <code>format=commas</code> || Numbers over 999 are formatted with commas. |- | <code>format=raw</code> || Use a hyphen (-) to indicate a negative date difference instead of a minus (−); a hyphen may allow the result to be used in a calculation. |- | <code>sep=comma</code> || Separator between items is a comma: 1 year, 2 months, 3 days. The default is 1 year, 2 months and 3 days. |- | <code>sep=,</code> || Same as <code>sep=comma</code>. |- | <code>sep=serialcomma</code> || Use a [[serial comma]]: 1 year, 2 months, and 3 days. |- | <code>sep=space</code> || Use a space: 1 year 2 months 3 days. |- | <code>sc=y</code> || Change the default separator to use a serial comma. Also accepts <code>sc=yes</code> and <code>sc=on</code>. |- | <code>show=y</code> || years |- | <code>show=ym</code> || years and months |- | <code>show=ymd</code> || years, months and days (default) |- | <code>show=ymw</code> || years, months and weeks |- | <code>show=ymwd</code> || years, months, weeks and days |- | <code>show=yd</code> || years and days |- | <code>show=m</code> || months |- | <code>show=md</code> || months and days |- | <code>show=w</code> || weeks |- | <code>show=wd</code> || weeks and days |- | <code>show=d</code> || days |- | <code>show=dh</code> || days and hours |- | <code>show=dhm</code> || days, hours and minutes |- | <code>show=dhms</code> || days, hours, minutes and seconds |- | <code>show=ymdh</code> || ymd + hours |- | <code>show=ymdhm</code> || ymd + hours and minutes |- | <code>show=ymwdh</code> || ymwd + hours |- | <code>show=ymwdhm</code> || ymwd + hours and minutes |- | <code>show=h</code> || hours (result would be 48 hours for a difference of 2 days) |- | <code>show=hm</code> || hours and minutes |- | <code>show=hms</code> || hours, minutes and seconds |- | <code>show=M</code> || minutes (uppercase <code>M</code> because <code>m</code> is months) |- | <code>show=s</code> || seconds |- | <code>round=on</code> || Round the least-significant unit specified with the <code>show=</code> parameter. |- | <code>round=months</code> || Round to nearest month using <code>show=ym</code>. |- | <code>round=weeks</code> || Round to nearest week using <code>show=ymw</code>. |- | <code>round=days</code> || Round to nearest day using <code>show=ymd</code>. |- | <code>round=hours</code> || Round to nearest hour using <code>show=ymdh</code>. |- | <code>sortable=on</code> || Output a hidden sort key based on the number of days in the date difference (includes a fraction of a day to handle time differences). |- | <code>sortable=off</code> || No sort key (default). |- | <code>sortable=debug</code> || Output a visible sort key for testing. |}
Edit summary
(Briefly describe your changes)
Please note that all contributions to A2wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
A2wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Documentation subpage
(
edit
)
Template:Lua
(
edit
)
Template:Mbox
(
edit
)
Template:No redirect
(
edit
)
Template:Plainlist/styles.css
(
edit
)
Template:Strong
(
edit
)
Template:Template link
(
edit
)
Template:Template shortcut
(
edit
)
Template:Template shortcuts
(
edit
)
Template:Terminate sentence
(
edit
)
Template:Time interval
(
edit
)
Template:Tl
(
edit
)
Module:Age
(
edit
)
Module:Arguments
(
edit
)
Module:Date
(
edit
)
Module:List
(
edit
)
Module:Lua banner
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Redirect
(
edit
)
Module:Shortcut
(
edit
)
Module:Shortcut/config
(
edit
)
Module:Shortcut/styles.css
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Template
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Current events
Random page
About A2wiki
interaction
Help
Community portal
Recent changes
Upload file
Tools
What links here
Related changes
Special pages
Page information