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

Template:MC/Years or months ago/doc

Template page

Template:Documentation header

This template 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.

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 April 2026 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
{{Years or months ago|2024|4}} Template:Years or months ago
{{Years or months ago|2025|4}} Template:Years or months ago
{{Years or months ago|2026|2}} Template:Years or months ago
{{Years or months ago|2026|3}} Template:Years or months ago
{{Years or months ago|2026|4}} Template:Years or months ago
{{Years or months ago|2026|5}} Template:Years or months ago
{{Years or months ago|2026|6}} Template:Years or months ago
{{Years or months ago|2027|4}} Template:Years or months ago
{{Years or months ago|2028|4}} Template:Years or months ago

Year only (no month)

Template Output
{{Years or months ago|2024}} Template:Years or months ago
{{Years or months ago|2025}} Template:Years or months ago
{{Years or months ago|2026}} Template:Years or months ago
{{Years or months ago|2027}} Template:Years or months ago
{{Years or months ago|2028}} Template:Years or months ago

See also