ComboStrap - Date Component

Deprecated

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:

Example

Today's date

  • The markup
<date/>
  • The output is a date formatted to the default format.

Tuesday, 16 April 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:

Apr 16

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.

Tuesday, 16 April 2024

Date specified manually

<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.

<date>$date_published</date>
  • The output will be:

Monday, 17 April 2023

Syntax

  • For the today's date
<date format="formatValue" lang="language"/>
  • When specifying a date value
<date format="formatValue" lang="language">dateValue</date>

where:

Task Runner