模板:Years or months ago/doc

来自决策链云智库
< 模板:Years or months ago
Zeroclanzhang讨论 | 贡献2024年1月18日 (四) 14:26的版本 (创建页面,内容为“{{Documentation subpage}} {{High-use}} <!-- Categories go at the bottom of this page and interwikis go in Wikidata. --> '''Template:Years or months ago''' displays the number of years (or months if less than 1 year) between a specified year/month date and the current year/month. It will also work correctly when only the year is given. Optionally, a second year/month date can be specified to be used instead of the current year/month. This was designed as a supp…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

Template:Years or months ago displays the number of years (or months if less than 1 year) between a specified year/month date and the current year/month. It will also work correctly when only the year is given. Optionally, a second year/month date can be specified to be used instead of the current year/month.

This was designed as a supporting template for Template:Start date and age, to be used when the specified date does not include the day of the month. The formatting of the output was designed to be similar to Template:Time ago.

Usage

For years or months before or after current date:

  • {{Years or months ago|year|month}}
  • {{Years or months ago|year}}

For years or months between two dates:

  • {{Years or months ago|year1|month1|year2|month2}}

Examples

The following examples use 11月 2024 as the current month and year. If that is not correct, click the Purge link at the top of this documentation (or here) to update the page.

Year and month

Template Output
11}} 2 years ago
11}} 1 year ago
9}} 2 months ago
10}} 1 month ago
11}} 0 months ago
12}} 1 month's time
1}} 1 year's time
11}} 1 year's time
11}} 2 years' time

Year only (no month)

Template Output
{{Years or months ago|2022}} 2 years ago
{{Years or months ago|2023}} 1 year ago
{{Years or months ago|2024}} 0 years ago
{{Years or months ago|2025}} 1 year's time
{{Years or months ago|2026}} 2 years' time

See also

  • Template:Time ago – displays elapsed time (with same singular or plural text as this template)
  • Template:Age – displays elapsed time in years (number only, future dates generate negative number)