Template:Date
From Drunkapedia
Syntax
This template takes up to two parameters, both of which are optional:
{{date|
<date to be formatted>|<date formatting style>}}
- <date to be formatted> is an (optional) date to be formatted.
- If no date is specified, the template emits the current date.
For example, {{date}} produces 5 December 2024. - If a date is provided, but is not recognized as one, the text is just returned as is. Most dates will however be recognized as such, including all the formats typically used on Wikipedia. Numerous variations thereof are also supported, including abbreviated or lower case month names; genitive 'st', 'nd', 'rd', 'th'; extraneous white space; missing comma etc.
- Notes:
- Some dates are converted even if they are not real dates, and some dates are not converted even though they are real dates. See known issues below.
- Only dates within the range 1 January 1000 and 31 December 9999 are supported. Dates with two digit dates will have unexpected results. Other dates outside the range 1000–9999 will be treated as if the second parameter were "none".
- If no date is specified, the template emits the current date.
- <date formatting style> controls the date format in which the result is to be emitted.
- If no style is specified, the template emits a date in 'd month yyyy' format, as it appears (for example) on discussion pages.
- Recognized values for the second parameter are:
- none applies no formatting whatsoever
- dmy gives d mmmm yyyy (eg 5 December). This is the default format.
- mdy gives mmmm d, yyyy (eg December 5)
- ymd gives yyyy mmmm dd (eg December 5)
- iso gives an ISO 8601 yyyy-mm-dd (eg December 5)
- Prefixing these parameters with "l" (l for link) produces a linked date:
- ldmy gives [[d mmmm]] [[yyyy]] (eg 5 December)
- lmdy gives [[mmmm d]], [[yyyy]] (eg December 5)
- lymd gives [[yyyy]] [[mmmm dd]] (eg December 5)
- liso gives [[yyyy]]-[[mm-dd]] (eg December 5)
- Notes:
- Although these are the four formats supported by MediaWiki's date autoformatting mechanism, only
dmy
/ldmy
andmdy
/lmdy
are in accordance with the English language Wikipedia's Manual of Style. The use ofiso
/liso
(ISO 8601) format within article prose is expressly discouraged by the Manual of Style; this format should only be used in tables or lists. - In each case, the result is exactly the same as what would be emitted by MediaWiki's date autoformatting mechanism.However, dates are not manipulated by MediaWiki's date autoformatting mechanism even when linked. This permits dates to have a consistent appearance regardless of whether they are linked or not.
- Although these are the four formats supported by MediaWiki's date autoformatting mechanism, only
Examples
Input | Output |
---|---|
No format specified | |
{{date|2006-05-04}} | 4 May 2006 |
{{date|May 4, 2006}} | 4 May 2006 |
{{date|4 May 2006}} | 4 May 2006 |
{{date|4 May}} | 4 May |
{{date|May 4}} | 4 May |
dmy format | |
{{date|2006-05-04|dmy}} | 4 May 2006 |
{{date|May 4, 2006|dmy}} | 4 May 2006 |
{{date|4 May 2006|dmy}} | 4 May 2006 |
{{date|4 May|dmy}} | 4 May |
{{date|May 4|dmy}} | 4 May |
mdy format | |
{{date|2006-05-04|mdy}} | May 4, 2006 |
{{date|May 4, 2006|mdy}} | May 4, 2006 |
{{date|4 May 2006|mdy}} | May 4, 2006 |
{{date|4 May|mdy}} | May 4 |
{{date|May 4|mdy}} | May 4 |
ymd format | |
{{date|2006-05-04|ymd}} | 2006 May 4 |
{{date|May 4, 2006|ymd}} | 2006 May 4 |
{{date|4 May 2006|ymd}} | 2006 May 4 |
{{date|4 May|ymd}} | May 4 |
{{date|May 4|ymd}} | May 4 |
iso format | |
{{date|2006-05-04|iso}} | 2006-05-04 |
{{date|May 4, 2006|iso}} | 2006-05-04 |
{{date|4 May 2006|iso}} | 2006-05-04 |
{{date|4 May|iso}} | May 4 |
{{date|May 4|iso}} | May 4 |
none format | |
{{date|2006-05-04|none}} | 2006-05-04 |
{{date|May 4, 2006|none}} | May 4, 2006 |
{{date|4 May 2006|none}} | 4 May 2006 |
{{date|4 May|none}} | 4 May |
{{date|May 4|none}} | May 4 |