ComboStrap - Date Component
The date component was deprecated for the date variable.
This article has been saved for historical purpose.
Why ?
- The function strftime was deprecated and will be no more available from php version 8
- The date format is not the standard.
- The pipeline format function can be enhanced to format also number.
About
With the date component, you could format any date:
- the today's date
- any string date
- or any page date attribute such as:
- date_created or date_modified of a page
- date_published (if specified, see The published date)
- date_start or date_end of an event
Example
Today's date
- The markup
<date/>
- The output is a date formatted to the default format.
Friday, 22 November 2024
To have it refresh every day, we expire the cache date daily
<cache expiration="@daily"/>
Today's date - short format
- Today's date with a short month description and the day number US style
<date format="%h %d"/>
- The output:
Nov 22
Today's date in French
- The markup with the locale attribute with just the region (ie country) as value.
<date locale="fr"/>
- The output is a date formatted with French word.
Friday, 22 November 2024
Date specified manually
- When you specify a date, you need to write it in a accepted date format
<date format="%A">2021-09-27</date>
- The output gives the day name of the date (ie %A)
Monday
Date of a page
You can even print a date metadata of a page.
- For instance, for the published date of this article
<date>$date_published</date>
- The output will be:
Friday, 22 November 2024
Syntax
- For the today's date
<date format="formatValue" lang="language"/>
- When specifying a date value
<date format="formatValue" lang="language">dateValue</date>
where:
- format is any format accepted by the strftime function
- language is a language value. You can also just use the country value (for instance, the value us is valid).
- dateValue is:
- one of the accepted date format
- or any page date metadata.