From c5f0f10f0a74c83f8ae92652a9cca33280a0fb71 Mon Sep 17 00:00:00 2001 From: WebVPF <61043464+WebVPF@users.noreply.github.com> Date: Tue, 20 Feb 2024 19:39:13 +0200 Subject: [PATCH] Add markup docs time filters (#173) --- markup/filters/time.md | 23 +++++++++++++++++++++++ markup/toc.yaml | 1 + 2 files changed, 24 insertions(+) create mode 100644 markup/filters/time.md diff --git a/markup/filters/time.md b/markup/filters/time.md new file mode 100644 index 00000000..42a915cc --- /dev/null +++ b/markup/filters/time.md @@ -0,0 +1,23 @@ +# time_since and time_tense + +The `time_since` and `time_tense` filters format time. + +## time_since + +Formats a human readable time difference from the value to the current time. Eg: **10 minutes ago** + +```twig +{{ '2021-03-06 14:25:55'|time_since }} + +{{ 'February 14, 2024 14:30'|time_since }} +``` + +## time_tense + +Formats 24-hour time and the day using the grammatical tense of the current time. Eg: Today at 12:49, Yesterday at 4:00 or 18 Sep 2015 at 14:33. + +```twig +{{ '2021-03-06 14:25:55'|time_tense }} +``` + +> **NOTE:** To format dates in Twig there is a [date filter](https://twig.symfony.com/doc/3.x/filters/date.html) diff --git a/markup/toc.yaml b/markup/toc.yaml index fb640cad..140dcca5 100644 --- a/markup/toc.yaml +++ b/markup/toc.yaml @@ -43,6 +43,7 @@ sections: filters/raw: "| raw" filters/resize: "| resize" filters/theme: "| theme" + filters/time: "| time_[since|tense]" filters/trans: "| trans" Functions: