User:Gaidheal/Templates/Date
Jump to navigation
Jump to search
15 November 2024
Description
This template converts a date to one of the standard date formats used on the English Wikipedia. This template is probably best used internally in other templates.
Do not subst this template in an attempt to obtain a permanent link to today's date, it will not work. Instead, use Template:Tlx
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, Template:Nowrap produces Template:Date.
- If no date is specified, the template emits the current date.
- 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 Template:Date and Template:Date 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".
- <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 Template:Date). This is the default format.
- mdy gives mmmm d, yyyy (eg Template:Date)
- ymd gives yyyy mmmm dd (eg Template:Date)
- iso gives an ISO 8601 yyyy-mm-dd (eg Template:Date)
- Prefixing these parameters with "l" (l for link) produces a linked date. Note: the Manual of Style explicitly discourages linking dates unless the linked article is relevant (see MOS:UNLINKDATES), thus this feature should seldom be used:
- ldmy gives [[d mmmm]] [[yyyy]] (eg Template:Date)
- lmdy gives [[mmmm d]], [[yyyy]] (eg Template:Date)
- lymd gives [[yyyy]] [[mmmm dd]] (eg Template:Date)
- liso gives [[yyyy]]-[[mm-dd]] (eg Template:Date)
- 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.
- Although these are the four formats supported by MediaWiki's date autoformatting mechanism, only
- 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.
- In each case, the result is exactly the same as what would be emitted by MediaWiki's date autoformatting mechanism.