Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Time diff

Security covered Under active development 51 sites

This module adds a Twig filter to display human-readable time differences between two dates. It formats these differences into user-friendly strings like "2 days ago" or "3 months ago".

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 }}

 

Drupal 9–11

Ask your assistant about Time diff

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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 PHP Release date
1.0.0 Stable 9–11 Aug 22, 2024
1.0.x-dev Dev 9–11 Aug 7, 2024