System:Template:niceDate
From Aspen Documentation
Prints a nicely formatted date. You may specify a format or use the default. Will properly handle empty or invalid dates eliminating the need for logic.
Since 1.0
Contents |
Arguments
string niceDate (string $date, [string $date_format_string = "n/j/Y"], [mixed $empty_string = '-'], [boolean $date_only = false])
- date
- Any string obtained from the php date function.
- date_format_string
- The format string to use if the data does not fall into any of the categories set.
- empty_string
- What to print if the date is invalid / empty.
- date_only
- Toggle skipping the nice date function and simply running the valid/empty check only.
Possible Nice Dates
Here is a list of possible nice dates that will be returned if date_only is false. If the date does not fall into any of the categories below the return value will default to $date_format_string.
| Logic | Return Value |
|---|---|
| $date == Today | Today |
| $date+1 == Tomorrow | Today |
| $date-1 == Yesterday | Yesterday |
| $date 0-7 days from now, this calendar week | This Week |
| $date 7 days from now, not this calendar week | Next Week |
| $date > 7 and <= 14 days away | Two Weeks |
| $date > 14 and <= 21 days away | Three Weeks |
| $date > 21 and <= 60 days away | Next Month |
| $date <0 and >-7 | Last Monday (day name) |
| $date 7 days ago | One Week Ago |