This project is not covered by Drupal’s security advisory policy.

Habeuk DateTime

Provides a custom field formatter for datetime fields with relative time display ("1 month ago", etc.) and SVG icons.

Features

  • Custom field formatter for datetime, timestamp, created and changed fields
  • Displays creation and/or modification dates with calendar and edit icons
  • Relative time display (e.g., "1 month ago", "2 days ago")
  • Configurable settings per field instance
  • Responsive Bootstrap 5 markup

Requirements

  • Drupal 10 or 11
  • PHP 8.1+

Installation

Install as you would normally install a contributed Drupal module.

Composer

composer require drupal/habeuk_datetime

Manual

  1. Download the module and place it in the modules/custom/ directory
  2. Enable the module: drush en habeuk_datetime

Usage

  1. Go to Manage display of your content type (or other entity)
  2. For any datetime, timestamp, created or changed field, select Habeuk Datetime Metadata as the format
  3. Click the settings icon to configure:
    • Show creation date: Display the date the entity was created
    • Show modification date: Display the date the entity was last modified
    • Show relative time: Display relative time (e.g., "1 month ago")

Configuration

Each field instance can be configured independently with these options:

Setting Description Default
Show creation date Display the creation date with calendar icon Yes
Show modification date Display the modification date with edit icon Yes
Show relative time Display "X time ago" next to the date Yes

Template

The module provides a theme hook habeuk_datetime_formatter that can be overridden in your theme:

templates/habeuk-datetime-formatter.html.twig

Variables

Variable Type Description
entity Object The entity being displayed
show_create_date Boolean Whether to show creation date
show_update_date Boolean Whether to show modification date
show_date_ago Boolean Whether to show relative time
created_formatted String Formatted creation date
created_relative String Relative creation time
changed_formatted String Formatted modification date
changed_relative String Relative modification time

Project information

  • Created by stephane888 on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases