[SPIP] Proposé : |normaliser_date

SPIP

Article proposé

L’article « |normaliser_date
(SPIP) » est proposé
à la publication depuis le samedi 22 juillet 2023.


|normaliser_date

samedi 22 juillet 2023 , par jack

The |normaliser_date filter will return a date in the form « Y-m-d H:i:s »
(Year-month-day Hour:minutes:seconds).

Applied to a tag returning a date in RFC 3339
(RFC 3339 - Date and Time on the Internet: Timestamps) format (2012-03-27T22:54:10Z), the
|normaliser_date filter will transpose the date into the form
« Year-month-day Hours:minutes:seconds » (2012-03-28 00:55:41).

Example :
Your date field (#DATE) is saved in « Y-m-d » format and does not take
hours, minutes or seconds into account. But you need to compare this date
with another date which does take hours into account. To make these two
elements comparable, you need to set your date to the correct format using
this filter :

[(#DATE|normaliser_date)]

This filter offers an additional option :
by giving it a « true » argument, the filter transforms all « -00 » values
(i.e. month or day not defined) into « -01 » values.
For example : [(#VAL{2012-00-00}|normaliser_date{true})],
will display : « 2012-01-01 00:00:00 ».

— Envoyé par SPIP (https://www.spip.net/)

rubon199-7e493.jpg