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,createdandchangedfields - 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_datetimeManual
- Download the module and place it in the
modules/custom/directory - Enable the module:
drush en habeuk_datetime
Usage
- Go to Manage display of your content type (or other entity)
- For any
datetime,timestamp,createdorchangedfield, select Habeuk Datetime Metadata as the format - 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.twigVariables
| 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
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
