====== ComboStrap - Date Component ====== The date component was deprecated for the [[howto:date|date variable]]. This article has been saved for historical purpose. Why ? * The function [[https://www.php.net/manual/en/function.strftime.php|strftime]] was deprecated and will be no more available from php version 8 * The date format is not the standard. * The [[:docs:templating:pipeline#format|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 [[docs:metadata:date_format|string date]] * or any [[docs:templating:variable|page date attribute]] such as: * ''date_created'' or ''date_modified'' of a page * ''date_published'' (if specified, see [[docs:page:published]]) * ''date_start'' or ''date_end'' of an [[docs:type:event|event]] ===== Example ===== ==== Today's date ==== * The markup * The output is a date formatted to the default format. To have it refresh every day, we expire the [[docs:cache:cache|cache date daily]] ==== Today's date - short format ==== * Today's date with a short month description and the day number US style * The output: ==== Today's date in French ==== * The markup with the [[docs:locale:locale|locale]] attribute with just the region (ie country) as value. * The output is a date formatted with French word. ==== Date specified manually ==== * When you specify a date, you need to write it in a [[docs:metadata:date_format|accepted date format]] 2021-09-27 * The output gives the day name of the date (ie ''%A'') ==== Date of a page ==== You can even print a date metadata of a page. * For instance, for the [[docs:page:published|published date]] of this article $date_published * The output will be: ===== Syntax ===== * For the today's date * When specifying a date value dateValue where: * ''format'' is any [[https://www.php.net/manual/en/function.strftime.php|format accepted by the strftime function]] * ''language'' is a [[:docs:locale:lang|language]] value. You can also just use the [[:docs:locale:region|country value]] (for instance, the value ''us'' is valid). * ''dateValue'' is: * one of the [[docs:metadata:date_format|accepted date format]] * or any [[docs:templating:variable|page date metadata]].