Template:Date formatter
This template compares two dates (start date
and end date
) and formats the output:
- If the dates are the same, it displays the single date.
- If the dates are different, it displays a range in the format: "December 7 – 9, 2024".
- If
end date
is missing, it outputs the start date, but formatted as string.
Usage
he template is designed to work with variables, such as <start date
and end date
>:
{{Date formatter |<start date>|<end date>}}
Parameters
Parameter | Description | Example |
---|---|---|
1 (required) | The starting date in the format YYYY/MM/DD . |
2024/12/07
|
2 (optional) | The ending date in the format YYYY/MM/DD . If not provided, the template will output "Invalid input." |
2024/12/09
|
Examples
The following examples use hard-coded dates, for examples sake.
{{Date formatter|2024/12/07|2024/12/07}}
December 7, 2024
{{Date formatter |2024/12/07 |2024/12/09}}
December 7 – 9, 2024
{{Date formatter |2024/12/07}}
December 7, 2024
{{Date formatter|2024/12/31|2025/01/01}}
December 31, 2024 – January 1, 2025