ComboStrap - Date Component
Table of Contents
About
With the date component, you can 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.
Thursday, 02 February 2023
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:
Feb 02
Today's date in French
- The markup with the lang attribute
<date lang="fr"/>
- The output is a date formatted with French word.
jeudi, 02 fvrier 2023
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
With a template component, you can even print a date metadata of a page.
- For instance, for the published date of this article
<template>
<date>$date_published</date>
</template>
- The output will be:
Sunday, 26 September 2021
Syntax
- For the today's date
<date format="formatValue" lang="langValue"/>
- When specifying a date value
<date format="formatValue" lang="langValue">dateValue</date>
where:
- format is any format accepted by the strftime function
- lang is a lang value
- dateValue is:
- one of the accepted date format
- or any page date metadata.