Template:Date

From Drunkapedia
Revision as of 17:46, 6 March 2009 by imported>Tlosk (New page: <includeonly>{{#switch:none |{{#iferror: {{#time:Y_M_d|{{{1|}}} }} | none }} <!-- #time: can't handle --> |{{#iferror: {{#expr: {{{1|}}}+0 }} |<!--not a pure number--> |{{#ifexpr...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 17 November 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".
  • <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 17 November). This is the default format.
    • mdy gives mmmm d, yyyy (eg November 17)
    • ymd gives yyyy mmmm dd (eg November 17)
    • iso gives an ISO 8601 yyyy-mm-dd (eg November 17)
    Prefixing these parameters with "l" (l for link) produces a linked date:
    Notes:
    • Although these are the four formats supported by MediaWiki's date autoformatting mechanism, only dmy/ldmy and mdy/lmdy are in accordance with the English language Wikipedia's Manual of Style. The use of iso/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.

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