Difference between revisions of "Template:Daterangedash/doc"

From blackwiki
Jump to navigation Jump to search
imported>Howcheng
imported>Howcheng
Line 40: Line 40:
 
| Month day year, both dates in same year
 
| Month day year, both dates in same year
 
| <nowiki>{{daterangedash|April 20 2015|May 14 2015|dmy}}</nowiki>
 
| <nowiki>{{daterangedash|April 20 2015|May 14 2015|dmy}}</nowiki>
| <nowiki>{{nowrap|April 20}}{{spaced ndash}}{{nowrap|May 14}} </nowiki>2015
+
| <nowiki>{{nowrap|April 20}}{{spaced ndash}}{{nowrap|May 14,}} </nowiki>2015
 
| {{daterangedash|April 20 2015|May 14 2015|mdy}}
 
| {{daterangedash|April 20 2015|May 14 2015|mdy}}
 
|-
 
|-

Revision as of 17:44, 21 September 2017

This template creates a date range with non-breaking spaces between the month and day, and {{spaced ndash}}.

Usage

{{daterangedash|Starting date|Ending date|Date format string}}

Both date values can be in any format accepted by PHP's strtotime() function.

  • Starting date is the starting date for the range.
  • Ending Date is the ending date for the range.
  • Date format string is one of the following:
    • dm: day month (1 January)
    • dmy: day month year (1 January 1900)
    • md: month day (January 1)
    • mdy: month day year (January 1, 1900) – note: a comma will be inserted

If both start and end dates are in the same year, the first year will be omitted. There is no error checking to ensure the start date occurs before the end date.

Examples

Description Template code Wikicode equivalent Rendered output
Date and month only {{daterangedash|2012-01-10|2012-02-28|dm}} {{nowrap|10 January}}{{spaced ndash}}{{nowrap|28 February}} 10 JanuaryTemplate:Spaced ndash28 February
Date month year {{daterangedash|January 1 1999|August 5|dmy}} {{nowrap|1 January}} 1999{{spaced ndash}}{{nowrap|5 August}} 2025 1 JanuaryTemplate:Sp 1999Template:Spaced ndash5 AugustTemplate:Sp 2025
Month day only {{daterangedash|September 11|September 15|md}} {{nowrap|September 11}}{{spaced ndash}}{{nowrap|September 15}} September 11Template:Spaced ndashSeptember 15
Month day year, both dates in same year {{daterangedash|April 20 2015|May 14 2015|dmy}} {{nowrap|April 20}}{{spaced ndash}}{{nowrap|May 14,}} 2015 April 20Template:Spaced ndashMay 14, 2015

See also