See something you'd like to change or add, but you've never edited an open encyclopædia before? This overview was written to help absolute beginners get started.

Template:Date

From A Storehouse of Knowledge
Jump to: navigation, search

Template: Date
Use on/in Articles, mainly
Use for Standardised and user-customisable display of dates
Category template applies to page (none)
Template Parameters
(See Template style manual).
Name Purpose Required? SMW property Comment
1 Date No (see note A) See below

The date parameter can be almost any string recognisable as a date. The template ultimately uses the php strtotime() function, [1] so anything that recognises should work.

Note the following

If the month is given by a number, such as in 12-6-2012, the second field (6) is taken as the month if hyphens are used, and the first field (12) is taken as the month if slashes are used.

  • 12-6-2012 gives Tue. 12th June, 2012Tue. June 12th, 2012
  • 12/6/2012 gives Thu. 6th December, 2012Thu. December 6th, 2012

You can avoid any uncertainty by including the month as text:

  • 12 June 2012 gives Tue. 12th June, 2012Tue. June 12th, 2012
  • December 6 2012 gives Thu. 6th December, 2012Thu. December 6th, 2012
Note A

This template allows for no date being supplied to simplify templates that might use this template but not have a date supplied. If no date is supplied, this template produces no output.

Limitation

At present, this template only produces accurate days of the week for years from 1801 onward (until Tue, 19 Jan 2038).

Formatting

The date is actually output twice, once in English, etc. format, with the date before the month, and once in U.S. format with the month before the date.

  • The first date is wrapped in a span with a class of "date".
  • The second date is wrapped in a span with a class of "USdate". By default, this span is hidden (CSS display:none).

In addition to the date as a whole, the formatting of some parts of the date can be controlled through CSS:

  • The day of the week part is wrapped in a span with a class of "day".
  • The ordinal indicator ('th', etc.) is wrapped in a span with a class of "ord".
  • Therefore, either part (or both) can be hidden by supplying a CSS style of display:none or the formatting can be changed in other ways.
    • For example, the CSS code span.USdate span.ord {display:none} will turn off the display of the ordinal indicator for a US date.
Personal tools
Namespaces

Variants
Actions
visitor navigation
contributor navigation
monitoring
Toolbox