Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Hijri Dates

5 sites No security coverage
View on drupal.org

This module adds support for the Hijri (lunar) calendar to your Drupal site, allowing you to display content dates in both Gregorian and Hijri formats. It automatically detects the interface language to display month names in Arabic or English and offers a central configuration for date corrections.

Hijri Dates provides Drupal sites with Hijri (lunar) calendar support for content dates. It integrates with core field formatters, Views, and Twig templates with automatic language detection and centralized date correction capabilities. Perfect for multilingual sites needing to display dates in both Gregorian and Hijri formats.

Features

  • Field formatters for timestamp, datetime, and daterange fields - works with all core date field types
  • Automatic language detection - displays Arabic or English month names based on the interface language
  • Global date correction - centralized configuration for moon sighting variations with field-level override options
  • Twig integration - filter and function for easy use in custom templates
  • Views compatibility - works with all Views date fields using the same field formatters
  • Developer API - clean service for programmatic date conversion in custom modules

Usage

Field formatters (works in content displays and Views):

  1. Go to Structure > Content types > [Type] > Manage display
  2. Click the gear icon next to any date field
  3. Check "Use Hijri calendar"
  4. Choose to use global correction (default) or set a custom correction
  5. Save the display settings

The module extends the standard Drupal date formatters, so it works anywhere date fields are displayed, including Views, entity displays, and field formatters.

Date Correction:

Global Correction (recommended):

  1. Go to Administration > Configuration > Regional > Hijri Dates Settings
  2. Enter the global date correction value (e.g., "+1 day")
  3. Save configuration

Field-level Correction (for special cases):

  1. In field display settings, uncheck "Use global date correction"
  2. Enter a custom correction value

Common correction values:

+1 day    # Common adjustment
-1 day    # Subtract one day

Twig templates:

{# Using filter syntax #}
{{ node.created.value|hijri }}
{{ node.created.value|hijri('medium') }}
{{ node.created.value|hijri('!Y/m/d', '+1 day') }}

{# Using function syntax #}
{{ hijri(node.created.value, 'medium', '+1 day') }}

PHP integration:

// Get the service
$hijri_service = \Drupal::service('hijri_dates.service');

// Basic usage
$hijri_date = $hijri_service->formatHijri($timestamp);

// With format and correction
$hijri_date = $hijri_service->formatHijri($timestamp, 'medium', '+1 day');

// With custom format
$hijri_date = $hijri_service->formatHijri($timestamp, '!Y/m/d');

// With DateTime objects
$date = new \DateTime('2023-05-15');
$hijri_date = $hijri_service->formatHijri($date);

Format Support

Supports standard PHP date format patterns:

  • l, D - Weekday names (full, short)
  • F, M - Month names (full, short)
  • j, d - Day of month (with/without leading zeros)
  • Y, y - Year (4-digit, 2-digit)
  • H, h, i, s - Time components

Incompatible: S, T, e, I, O, P, Z, c, r, U (timezone and special formats)

Language Handling

  • Arabic interface: Arabic month/day names and numerals (e.g., "٢٢ رجب ١٤٤٦")
  • English interface: Transliterated names and Western numerals (e.g., "Rajab 22, 1446")

Requirements

  • Drupal 9/10
  • ArPHP Library (^7.0.0, automatically installed via Composer)

The module now includes a configuration page at Administration > Configuration > Regional > Hijri Dates Settings for managing global date correction.

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
3
Tracked since
Jun 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 3
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.0.0-alpha3 Pre-release 9–10 Jun 22, 2025
1.0.0-alpha2 Pre-release 9–10 Jun 22, 2025
1.0.0-alpha1 Pre-release 9–10 Jun 22, 2025