[SPIP] PUBLIE : |normaliser_date


Article validé

L’article « |normaliser_date
(|normaliser_date - SPIP) » vient d’être publié par


dimanche 30 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 :


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/)