Difference between revisions of "Template:Birth date and age"

From Free Music Wiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#if:{{{3|}}}
+
<includeonly>{{#if:{{{df|}}}
   | {{{1}}} {{#switch:{{{2}}}|1=January|2=February|3=March|4=April|5=May|6=June|7=July|8=August|9=September|10=October|11=November|12=December}} {{{3}}}
+
   | {{#expr:{{{1}}}}} {{MONTHNAME|{{{2}}}}} {{{3}}}
   | {{#if:{{{2|}}}
+
   | {{#switch:{{{2}}}|1=January|2=February|3=March|4=April|5=May|6=June|7=July|8=August|9=September|10=October|11=November|12=December}} {{#expr:{{{1}}}}}, {{{3}}}
    | {{#switch:{{{2}}}|1=January|2=February|3=March|4=April|5=May|6=June|7=July|8=August|9=September|10=October|11=November|12=December}} {{#expr:{{{1}}}}}
+
}} (aged {{#expr:{{CURRENTYEAR}}-{{{3}}}-{{#ifexpr:{{CURRENTMONTH}}<{{{2}}}
    | {{{1}}}
+
  or ({{CURRENTMONTH}}={{{2}}} and {{CURRENTDAY}}<{{{1}}})|1|0}}}})</includeonly><noinclude>
  }}
 
}} ({{#expr:{{CURRENTYEAR}} - {{{{{1}}}|{{{2}}}|{{{3}}}}}}})<!--
 
-->{{#ifexpr:{{CURRENTMONTH}} > {{{2}}} or {{CURRENTMONTH}} = {{{2}}} and {{CURRENTDAY}} >= {{{1}}}
 
  | {{#expr:{{CURRENTYEAR}} - {{{3}}}}}
 
  | {{#expr:{{CURRENTYEAR}} - {{{3}}} - 1}}
 
}} years old</includeonly><noinclude>
 
 
{{Documentation}}
 
{{Documentation}}
 
[[Category:Date mathematics templates]]
 
[[Category:Date mathematics templates]]
 
</noinclude>
 
</noinclude>

Latest revision as of 04:49, 19 May 2026

Template documentation
  Warning: This page is not a documentation subpage, but it is using {{Documentation subpage 
 | {{Documentation subpage}}

}} incorrectly. Please use it only on pages named /doc in the template namespace.

This template displays a birth date and automatically calculates the person's current age.

Usage

{{Birth date and age|day|month|year}}
  • `day` – day of month (1–31)
  • `month` – month number (1–12)
  • `year` – four-digit year

Examples

Code Output
{{Birth date and age|2008|4|14}} April 2008, 14 (aged 2012)
{{Birth date and age|2000|1|1}} January 2000, 1 (aged 2025)

Formatting options

  • Add |df=yes for day-first format (already default in many wikis)
  • Add |mf=yes for month-first format (April 14, 2008)

See also

 | {{Death date and age}}

}}

 | {{Birth date}}

}}

 | {{Age}}

}}

Editors can experiment in this template's sandbox and testcases pages.
Please add categories and interwikis to the /doc subpage.