Template:Time interval
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 pro…
| This template uses Lua: |
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
{{time interval|date1|date2|options}}
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 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:
{{time interval|1 Jan 2001|March 4, 2002}}→ 1 year, 2 months and 3 days{{time interval|1 Jan 2001|March 4, 2002|abbr=on}}→ 1y 2m 3d{{time interval|B.C.E. 1 Feb 120|28 FEB 1900}}→ 2019 years and 27 days
Parameters
| Parameter | Description |
|---|---|
abbr=off |
Unit names in full (default): year, month, day, hour, minute. |
abbr=on |
Units shown as a single letter with no space between number and unit: y, m, d, h, m. |
disp=age |
If no show 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 sep=space by default. This is compatible with {{age for infant}}.
|
disp=raw |
Display numbers only with sep=space.
|
duration=on |
Period is a duration (has an extra day to include the end date). |
format=commas |
Numbers over 999 are formatted with commas. |
format=raw |
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. |
sep=comma |
Separator between items is a comma: 1 year, 2 months, 3 days. The default is 1 year, 2 months and 3 days. |
sep=, |
Same as sep=comma.
|
sep=serialcomma |
Use a serial comma: 1 year, 2 months, and 3 days. |
sep=space |
Use a space: 1 year 2 months 3 days. |
sc=y |
Change the default separator to use a serial comma. Also accepts sc=yes and sc=on.
|
show=y |
years |
show=ym |
years and months |
show=ymd |
years, months and days (default) |
show=ymw |
years, months and weeks |
show=ymwd |
years, months, weeks and days |
show=yd |
years and days |
show=m |
months |
show=md |
months and days |
show=w |
weeks |
show=wd |
weeks and days |
show=d |
days |
show=dh |
days and hours |
show=dhm |
days, hours and minutes |
show=dhms |
days, hours, minutes and seconds |
show=ymdh |
ymd + hours |
show=ymdhm |
ymd + hours and minutes |
show=ymwdh |
ymwd + hours |
show=ymwdhm |
ymwd + hours and minutes |
show=h |
hours (result would be 48 hours for a difference of 2 days) |
show=hm |
hours and minutes |
show=hms |
hours, minutes and seconds |
round=on |
Round the least-significant unit specified with the show= parameter.
|
round=months |
Round to nearest month using show=ym.
|
round=weeks |
Round to nearest week using show=ymw.
|
round=days |
Round to nearest day using show=ymd.
|
round=hours |
Round to nearest hour using show=ymdh.
|
sortable=on |
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). |
sortable=off |
No sort key (default). |
sortable=debug |
Output a visible sort key for testing. |
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.