Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Luxon Date Field Formatters

Security covered Under active development 2 sites

This module allows you to display datetime field values in a visitor's local timezone and language using the Luxon JavaScript library. It leverages the browser's understanding of the user's time and language settings to format dates and times client-side, enabling page caching while providing a localized experience. The module offers both preset and custom formatting options, with additional features for date ranges like compression to avoid redundant information.

Use Luxon to localize datetime field output, client-side, showing dates and times in the visitor's local timezone.

Localizing dates client-side allows a site to display localized dates and times for all visitors (anonymous included) while keeping page cache enabled.

This module does not attempt to geo-locate visitors. It takes a less complex and arguably more accurate approach to date and time localization.

The visitor's browser already knows the visitor's timezone and language. Drupal knows what date/time you're trying to show. This module simply passes that date/time to the browser and asks the browser to do the work of localizing it for the visitor, showing the date/time in the visitor's local timezone, in a format of your choosing. Some format choices (presets) will go one step further and even show the date/time in the visitor's local language, with date parts ordered as is customary for that language.

Most of this is possible today in pure JS, but Luxon brings us an impressive array of formatting options, fallbacks for older browsers, a more simplified module codebase, and an excellent developer experience.

Datetime, datetime range, and timestamp field formatters

  • Luxon preset
    • Select a Luxon preset format
    • Select a fallback / server-side Drupal datetime format
    • For date ranges, optionally turn on compression to reduce repeated date parts in start and end dates (eg. "October 14, 1983 at 1:30 PM EDT - October 14, 1983 at 2:30 PM EDT" becomes "October 14, 1983 at 1:30 - 2:30 PM EDT"')
  • Luxon custom
    • Enter a custom Luxon datetime format using luxon tokens
    • Enter a fallback / server-side datetime format using PHP tokens
    • For date ranges, optionally turn on compression to reduce repeated date parts in start and end dates (eg. "October 14, 1983 at 1:30 PM EDT - October 14, 1983 at 2:30 PM EDT" becomes "October 14, 1983 at 1:30 - 2:30 PM EDT"')

Requirements

Built copy of Luxon 3.x in libraries folder, such that luxon.min.js is available at sites/../libraries/luxon/build/global/luxon.min.js.

Drupal 9–10 · not 11

Ask your assistant about Luxon Date Field Formatters

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

  • datetime Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Apr 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
1.0.0 Stable 9–10 Nov 22, 2023
1.0.0-beta3 Pre-release 9–10 Jun 8, 2023
1.0.0-beta2 Pre-release 9–10 May 11, 2023
1.0.0-beta1 Pre-release 9–10 May 4, 2023
1.0.x-dev Dev 9–10 Apr 28, 2023