Problem/Motivation

#3490066: Add shorter date format (without time) and start using in announcements feed showed a need for a shorter date format without time, showing the date only. Several users agreed that it would be nice to offer this:

I agree a date format in core for date only (without time) would be good.

The task of adding the shorter date format in the announcements feed has been transferred to this issue:

@penyaskito:

[...] the change on announcements is a 1-line change in a template that we can fit on the other one, and is already approved by UX Lead and Product Manager, so shouldn't add any overhead.

Steps to reproduce

Open Administration > Configuration > Region and language > Date and time formats (/admin/config/regional/date-time) and see that all human readable date formats include time.

See the announcement feed, and think a shorter date format would be nice.

Proposed resolution

It would be nice to offer human readable date formats, without time:

Name Pattern
Default long date (date only) Saturday, 11 January 2025
Default medium date (date only) Sat, 11 Jan 2025
Default short date (date only) 11 Jan 2025

It was considered to remove and deprecate Olivero Medium date format, but this is a bigger task, and will be handled in #3529846: Deprecate and remove Olivero Medium date format.

Remaining tasks

User interface changes

  • All sites offer shorter human readable date formats, without time, showing only the date.
  • The announcement feed uses the short date-only date format.

After

API changes

Data model changes

Translations

Issue fork drupal-3498980

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

ressa created an issue. See original summary.

ressa’s picture

ressa’s picture

ressa’s picture

Issue summary: View changes

Update formats in Issue Summary.

ressa’s picture

Status: Active » Needs review
ressa’s picture

Issue summary: View changes
smustgrave’s picture

Category: Task » Feature request

Going to have and look at this later. Not sure why migration test had to be updated

ressa’s picture

Thanks for looking at this so fast.

It's the function below. And since there are three more date formats, the date_format count increases from 12 to 15:

  /**
   * {@inheritdoc}
   */
  protected function getEntityCounts(): array {
    return [
      'block' => 37,
      'block_content' => 2,
      'block_content_type' => 1,
[...]
      'date_format' => 15,
      'entity_form_display' => 23,
      'entity_form_mode' => 1,
      'entity_view_display' => 33,
      'entity_view_mode' => 11,
      'base_field_override' => 2,
    ];
  }

In:

  • /core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
  • /core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems like a fine addition and no objection. I didn't see any recipe that was installing datetime formats

Also doesn't feel like something that would need test coverage as just offering more options.

ressa’s picture

At the risk of repeating myself, the Needs Review Queue Initiative is among the best things to happen to Drupal the last few years, and the community can't be grateful enough, so thank you @smustgrave!

catch’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs product manager review

Very minor but I'm wondering if these could be e.g. 'Medium date (without time)', rather than starting with 'no time'.

Since this is user-facing tagging for product manager review.

ressa’s picture

Status: Needs review » Active

Thanks @catch, great suggestion and I updated the id's and labels. Perhaps you can review and check if "Needs Review" by product manager is still the case?

ressa’s picture

Issue summary: View changes

Update format names in Issue Summary.

catch’s picture

@ressa yes it changes out of the box behaviour so I think it could use it.

ressa’s picture

Status: Active » Needs review

Sorry if it wasn't clear, I just meant that if it still looks good to you after my update, then you should feel free to change status to Needs Review :)

PS. I updated the Status, but of course feel free to revert, if after reviewing the new MR, you think it needs more work.

lauriii’s picture

Seems fine from product perspective. I've wondered several times myself why we don't have these out of the box 🥲

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @lauriii!

quietone’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new23.43 KB

Just a few questions

Why is this change limited to new installs?

I did a fresh install with this MR and there are now two identical formats, 'Olivero Medium' and 'Short date (without time)'. I think that is confusing and should be addressed somehow.

And, can we use a more positive description, "Short date (date only)" instead of "Short date (without time)".

Setting to NW for responses to the above.

ressa’s picture

Issue summary: View changes

Thanks for the feedback @quietone, I have updated to use "(date only)" from "(without time)".

About "Olivero Medium" I am not sure, so I have updated the Issue Summary, with these Remaining tasks:

  • Add the three date formats above.
  • Figure out what to do with "Olivero Medium", since it has the same format as "Short date (date only)".
  • Should existing installations also get these date only formats, via an update hook?
ressa’s picture

Issue summary: View changes
penyaskito’s picture

  • I'd replace "Olivero Medium" with the new one, here or maybe even on a follow-up.
  • Should existing installations also get these date only formats, via an update hook? Yes, if there aren't pre-existing date formats with the same machine names.
ressa’s picture

Thanks for clearing that up so quickly @penyaskito, if you have time, feel free to update the MR with your suggestions. Maybe the update hook is safe to add, as a first step?

catch’s picture

Good idea to remove the Olivero date format. My main concern with this issue is that it's a lot of default date formats, but if we're able to start getting rid of one-off ones, that's a good trade-off.

ressa changed the visibility of the branch 3498980-add-date-formats to hidden.

ressa’s picture

Issue summary: View changes
Status: Needs work » Needs review

I somehow managed to make an update hook for existing installations, so they now also get these date only formats. But only if there aren't pre-existing date formats with the same machine names.

I also removed Olivero Medium data format. It is replaced with the new Short date format, in the Olivero theme. Luckily, if for some reason a date format cannot be found, the fallback date format is used.

PS. I had to close the original branch, and start fresh, since rebasing was not possible. Oh, and Nightwatch had to be re-run three times, before it finally went green :)

penyaskito’s picture

Title: Add date formats without time » Add date-only date formats
Component: user system » system.module
Status: Needs review » Needs work
Issue tags: +Needs upgrade path tests

See MR comments.
Also tagging for required upgrade path tests.

ressa’s picture

Issue summary: View changes

Thank you very much @penyaskito for fast and thorough review, I greatly appreciate it.

I have made the changes you suggested, and your new method for setting the date formats were spot on, so that made it a lot easier. I also restored olivero_medium format.

As you suggested in the original Announcement issue, I have updated the date format to short_date_only in this MR as well.

I have updated Remaining tasks, and added the upgrade path test task as well. I wonder if there is a documentation page on how to write upgrade path tests, going from Drupal 10 to 11 (I guess)?

ressa’s picture

Title: Add date-only date formats » Add date-only date formats, and use in Announcements Feed

Just updating the title, since the Announcement date update will also get done here.

ressa’s picture

Issue summary: View changes
catch’s picture

I don't think we need an update here, they can just be available on new sites. Even if existing sites don't have formats with the same names, they may have all kinds of custom formats already created which are similar, and then suddenly these new ones would appear alongside them. Similarly we often don't even fix arguable bugs in shipped views like admin/content in update paths, because there is a higher chance of breaking a site than fixing it.

quietone’s picture

Just came back to this. My question,"Why is this change limited to new installs?" was truly a question. It was not an implication that any work was needed to change that decision. Apologies for the confusion.

penyaskito’s picture

Issue summary: View changes
Issue tags: -Needs upgrade path tests

Oh, really? Then 🚀 ship it. @pameeela said this already, but I was pretty sure this was one of the core gates.

That means we need to actually remove that upgrade from this MR and we're done.

We don't need upgrade tests if there's no upgrade. Removing tag.
@ressa For the sake of learning, see https://www.drupal.org/docs/drupal-apis/update-api/writing-automated-upd...

Updated issue summary.
Only left: Revert

  • Add an update hook, so existing installations also get the new date only formats.
  • ressa’s picture

    Status: Needs work » Needs review

    Thanks for clearing that up @catch, and that's totally all right @quietone. As a side effect I realized what a useful feature the ddev snapshot command is, to quickly roll back changes. I also learned a bit or two about making a hook_update and running phpcs, so it turned out to be a gain after all. I am pasting the end result below, just in case someone else needs to do something similar in the future. Thanks for the Doc page link @penyaskito!

    Unused hook_update code:

    use Drupal\Core\Datetime\Entity\DateFormat;
    
    /**
     * Add date-only date formats.
     *
     * @see https://www.drupal.org/project/drupal/issues/3498980
     */
    function system_update_11202(): string {
      $message = NULL;
      $date_formats = [
        'long_date_only' => [
          'label' => t('Long date (date only)'),
          'pattern' => t('l, j F Y', [], ['context' => 'PHP date format']),
        ],
        'medium_date_only' => [
          'label' => t('medium date (date only)'),
          'pattern' => t('D, j M Y', [], ['context' => 'PHP date format']),
        ],
        'short_date_only' => [
          'label' => t('short date (date only)'),
          'pattern' => t('j M Y', [], ['context' => 'PHP date format']),
        ],
      ];
      foreach ($date_formats as $id => $date_format_info) {
        if (!DateFormat::load($id)) {
          $date_format = DateFormat::create([
            'id' => $id,
            'locked' => FALSE,
            'status' => TRUE,
            'pattern' => $date_format_info['pattern'],
            'label' => $date_format_info['label'],
          ]);
          $message .= "Date format " . $date_format_info['label'] . " was created.\n";
          $date_format->save();
        }
      }
      return $message;
    }
    penyaskito’s picture

    Status: Needs review » Needs work

    Tested this locally and found the sorting in the listing a bit weird. I think it would be better to prefix the labels.
    I won't do it myself so I can still RTBC.

    PS: don't try to test on the MR tugboat because it doesn't trigger a new install.

    penyaskito’s picture

    Issue summary: View changes
    penyaskito’s picture

    Status: Needs work » Reviewed & tested by the community

    Thanks for the quick response 😊

    ressa’s picture

    Issue summary: View changes

    You're welcome! And great catch, the order is much better now.

    mstrelan’s picture

    This is probably a duplicate of #2960821: Add default date formats without time but this has obviously had much more recent discussion. Perhaps someone could credit @dead_arm for the original issue I've just closed.

    mstrelan’s picture

    Status: Reviewed & tested by the community » Needs work

    Do we need a CR for the new formats and the removal of Olivero Medium? We had one last time formats changed - https://www.drupal.org/node/3467774

    In general I agree with removing Olivero Medium, but isn't it possible there are existing configs depending on this? I found at least 38 references in code after filtering out the cruft - https://git.drupalcode.org/search?group_id=2&scope=blobs&search=olivero_...

    These tend to be in recipes, formatter config, views fields and tokens.

    I think maybe we need a follow up to deprecate and remove it.

    ressa’s picture

    Issue summary: View changes
    Status: Needs work » Needs review

    Great catch @mstrelan, and @penyaskito also noticed this ("olivero_medium shouldn't be deleted. We know how it's being used in core, but not how could be used in contrib/custom sites.")

    So In the end, "Olivero Medium" was not removed. The only Olivero theme-related change was Olivero theme using a new format:

    Update Olivero theme to use "Default short date (date only)" instead of "Olivero Medium".

    But since the "Olivero Medium" date format stays, and you documented many more places where olivero_medium is in use, I removed the Olivero theme update as well. (And great way to use GitLab to search the code base of all contrib projects, BTW!)

    So now this MR only adds three new date only date formats, and updates the Announcements feed to use short_date_only.

    But this may need a change record? I have created a draft Default date formats have been expanded with date only formats.

    penyaskito’s picture

    Status: Needs review » Needs work

    I'm not sure how we deprecate a config entity. But definitely we should have a specific change record for the olivero date format.

    ressa’s picture

    Status: Needs work » Needs review

    But the Olivero format is not touched, please check my last comment or the MR.

    ressa’s picture

    Issue summary: View changes

    Adding "Review Change record Default date formats have been expanded with date only formats" in Issue summary under Remaining tasks".

    ressa’s picture

    penyaskito’s picture

    In #44 I expected that we would do the deprecation (but not the removal) here. That's why I suggested a new change record.

    ressa’s picture

    Status: Needs review » Needs work

    All right, perhaps it's most efficient, if you update the Issue Summary to more precisely reflect the remaining tasks? The other issue probably then also needs to be updated.

    ressa’s picture

    Issue summary: View changes

    @mstrelan and @penyaskito: I have added deprecating Olivero Medium in the Issue Summary here, and updated the Change Record with this:

    Olivero Medium has been deprecated and removed

    ToDo: Add description about what this means.

    Perhaps only the three new "date only" formats and deprecation Olivero Medium should be part of that Change Record, and the actual removal in a separate Change Record?

    mstrelan’s picture

    FWIW I think deprecation should be a separate issue and not even discussed here, make this easier to get in.

    ressa’s picture

    Issue summary: View changes
    Status: Needs work » Needs review

    Thanks for a fast answer @mstrelan, and I agree -- getting this small change completed by itself would be optimal, and then dealing with the complicated stuff in a follow up issue. I have updated issues and Change Record.

    Perhaps -- if you have time -- you could check the Change Record, which is the last remaining task? And I guess maybe also the MR, since it was updated 10 June 2025 to only add three new date formats, and update the date in the Announcements Feed.

    smustgrave’s picture

    Status: Needs review » Reviewed & tested by the community

    Tweaked the CR slightly for 11.3 rest seems fine to me!

    ressa’s picture

    Thanks @smustgrave!

    quietone’s picture

    Issue summary: View changes
    StatusFileSize
    new57.17 KB

    I removed 'proposed' from the CR and added a screenshot to the issue summary.

    Everything appears to be in order here.

    xjm’s picture

    Status: Reviewed & tested by the community » Needs review
    Issue tags: +Usability

    I can see adding one of these new formats, but adding three of them is essentially almost doubling the number of date formats. Perhaps we should just pick one to include? I find the new list kind of overwhelming. I think this would need usability review in addition to product signoff. (Meaning, we would want to add before-and-after screenshots and then tag it for usability review.)

    Also, given that these are only being added to new installs, but we are also changing the production Twig template for the announcements feed, that could be a problem, no? So that might be a reason we actually would need an upgrade path, at least for the one that Announcements is now expecting to exist. No?

    If folks are comfortable with adding just one date-only format, that change can be made and then we can go for a usability review. Otherwise, if folks feel strongly about adding all three, we should add the before screenshot and tag for usability review now.

    ressa’s picture

    Thanks for reviewing this @xjm. Looking at the list again, you have a point and I tend to agree ... Maybe we should only add a new short date without time format?

    Name Pattern
    Default short date (date only) 11 Jan 2025

    About an upgrade path for the announcements feed Twig template, you may be right ...

    penyaskito’s picture

    #56: For context, this came from #3490066: Add shorter date format (without time) and start using in announcements feed, which came from Drupal CMS 1.0 dashboard designs (#3489989: Announcements date format in Drupal CMS Dashboard)

    We needed just one date format. Before that, announcements had the same need, which happened in Olivero, because it didn't make sense to show the time when relevant announcements are quite spaced in time.

    Then it was about adding the 3 different date formats for consistency, which felt interesting.

    This might be a very small thing and even feels embarrassing referring to the strategy, but #3533440: Drupal Core strategy: July 2025 mentions:

    What ships with Drupal Core?
    [...]
    2. Ensure consistency and/or high-quality:

    * We add a feature to Drupal Core when it ensures consistency across all Drupal sites, or when it helps avoid contributed modules competing (reduce fragmentation).

    Having each module (like core announcements, Olivero, dashboard, Drupal CMS, or any of the future site templates) providing a single (or a couple of) date format(s) for fitting their needs can be even worse in terms of an overwhelming amount of date formats, plus producing design inconsistencies.

    Having these three would reduce the chances of that.

    smustgrave’s picture

    +1 for adding all 3

    mstrelan’s picture

    Status: Needs review » Needs work

    NW for #56:

    Also, given that these are only being added to new installs, but we are also changing the production Twig template for the announcements feed, that could be a problem, no? So that might be a reason we actually would need an upgrade path, at least for the one that Announcements is now expecting to exist. No?

    I installed standard profile on 11.x HEAD, then applied the patch from this branch and ran db updates. Before the patch the dates looked like "19 Jun 2025 - 05:05" and after like "Thu, 19 Jun 2025 - 05:05". This is because \Drupal\Core\Datetime\DateFormatter::format uses the "fallback" format if the format doesn't exist. So while we're not breaking anything, we are making it worse for existing sites. So we should probably do an update hook to install one or all new formats, but only if there isn't an existing format with the same name.

    penyaskito’s picture

    In #33 we were told no upgrade path needed, which we had already written (see #36).
    Now we are at 60 comments for amending some date formats.

    catch’s picture

    I still think that adding all the formats to existing sites would be confusing (to be honest I also still think this issue could just add the one date format instead of three but I am neither a UX nor product manager).

    If we need to add exactly one new date format, checking for existing formats with the same name, we could do that - but IMO that should only happen in the announcements feed module then, so that it only gets added for sites with that module enabled. This would not be the same update as the one that was removed after #33, maybe some of the logic can be re-used though.

    Version: 11.x-dev » main

    Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

    Read more in the announcement.