Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markup docs time filters #173

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions markup/filters/time.md
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions markup/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ sections:
filters/raw: "| raw"
filters/resize: "| resize"
filters/theme: "| theme"
filters/time: "| time_[since|tense]"
filters/trans: "| trans"

Functions:
Expand Down
Loading