The existing TimestampCeFieldFormatter supports timestamp, created, and changed fields which store Unix timestamps. However, datetime and daterange fields store ISO date strings (e.g., 2025-04-10T09:00:00) and are not supported.
There is no built-in custom elements formatter for datetime and daterange field types. Users needing formatted date output with timezone and date format support for these field types must write a custom formatter.

Solution
Add a DateTimeCeFieldFormatter that extends TimestampCeFieldFormatter to support datetime and daterange fields. It:

  • Reuses the same configuration form (date format, custom format, timezone)
  • Parses ISO date strings via DrupalDateTime instead of using DateFormatterInterface::format() (which expects Unix timestamps)
  • Handles daterange fields by outputting {value, endValue} objects
  • Supports single and multi-cardinality fields
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kushal bansal created an issue. See original summary.

fago’s picture

Status: Active » Needs work

thx! that would make sense, yes.

I've added a remark to the PR. Also I miss the configruation form and summary method implementations?

Then, same as for other formatters, please add a test-case that proofs it working.

kushal bansal’s picture

Status: Needs work » Needs review
fago’s picture

also, we need to watch out for date-only values and do no timezone conversion there.

fago’s picture

I addressed my remarks and added test coverage for changes. please review.

kushal bansal’s picture

Hi , I had a review and all looks goo to me. Thanks

  • fago committed 54e08653 on 3.x authored by kushal bansal
    feat: #3584113 Add ce-formatter for datetime and daterange fields
    
    By:...
fago’s picture

Status: Needs review » Fixed

Thank you, merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.