Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: MCP Sentinel 2.28.2 — Minor update available for module mcp_sentinel (2.28.2). Release: Rightup theme 1.0.2 — Minor update available for theme vartheme_bs5_rightup (1.0.2). Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage. Module Revived: Liquid Voting 2.0.1 — Module liquid_voting updated after 6 months of inactivity (2.0.1).

Twig Time Difference Filter

Introduction

The Twig Time Difference Filter module provides a convenient and powerful Twig filter for Drupal sites, allowing developers to display human-readable time differences between two dates or the current time. This module is particularly useful for content that needs to show relative time differences, such as “2 days ago”, “3 months ago”, or “1 year ago”.

Features

  • Easy Integration: Simple to use in any Twig template.
  • Human-Readable Formats: Automatically formats time differences into a user-friendly string like “just now”, “5 minutes ago”, or “2 years ago”.
  • Flexible Input: Supports various date formats and automatically handles the current date if the end date is not provided.

Usage

Once enabled, you can use the time_diff filter in your Twig templates:

{% set start_date = '2023-01-01' %}
Time Difference: {{ start_date|time_diff }}

Or convert it from entity creation time like:

{{ node.created.value|time_diff }}

 

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Aug 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.0 Stable Aug 22, 2024
1.0.x-dev Dev Aug 7, 2024