Date picker only works with US date and time formats

Created on 12 January 2018, almost 7 years ago
Updated 21 August 2024, 3 months ago

Problem/Motivation

Up to Drupal 7, the default date format was the ISO standard YYYY-mm-dd Commands:HH:mm. So where the date format, couldn't be set (such in the node/add forms) this was used.
Users could also add a timezone correction, such as (+2). There is an issue for this regression ✨ [PP-1] Add ability to select a timezone for datetime field Postponed .

In Drupal 8, a new "Fallback date format". This usese the US date format mm-dd-YY and a 12 hour clock with am/pm.
This date format is used in the US and a few other countries such as Marshall islands. The 12 hour clock with the am/pm suffix is only used in English and some Spanish speaking countries. Other languages don't have this concept for writing down times, and also no translation for "am/pm".

The date picker widget is hard-coded to use this fallback date format. This means that whenever uses the date picker, afterwards the form will display this US date format - no matter what other date formats the site uses. The user cannot change this.
Anybody who wants to type in the date is only sees mm/dd/yyyy.
This cannot be translated, even though it at least should be for example mm-tt-jjjj in German.

The time can be typed in the 24 hr format, but is then automatically changed to 12 hr format. Users have to choose AM or PM even if they have no idea what that means.

An example: If I enter date and time today using the date picker widget on a German Drupal site today, I expect something like 12-01-2018 16:00.
But what I see is 01/12/2018 04:00:00 pm. To me that looks like I mistyped, and I might correct it until I notice that it's getting changed every time. Or might look at this in a year or so, and wonder why I picked the wrong date....

I expect 12/01/2018 16:00 here.

If the user adds a date field to an entity this can at least be mitigated by choosing the select fields instead. That way we loose the ease of the date picker, but at least the date and time in the filled-in form doesn't look wrong.

However, the date picker widget is also hard-coded to be used for the "Authored on" field of the article and page content type. The user cannot change this, and it's not even possible to add any description text, to alert other users of the fact that this is in the US date format. This is even more confusing, when the short date format has been changed, because then the user sees two different date formats with no indication that this is the case. So it looks like two different dates.
To add insult to injury: the hard-coded description text still says that the date is in the format yyyy-mm-dd Commands:HH:mm.

So for the improved UX of having a date picker, we end up with one that only makes sense in the US, and a confusing UX experience for anybody outside the US who looks at the "Authored on" date on a node edit form.

Proposed resolution

The best solution would be if users could set the date format in which the picked date is displayed on the form.

This would ideally include both the order of day, month and year; their display; and the connectors (/ or - or so); as well as the display of the time. Obviously it needs ensuring that all 6 values are present.
Adding the timezone correction would fix the regression from D7 to D8 for the authored date for node content.

If this is not possible then there should at least should be two or three date options to choose from (yyyy-mm-dd, dd-mm-yyyy, mm/dd/yyyy) and the option to choose between 24 or 12 hr clock.

And the description text for the node edit form needs to be changed to reflect the changed date format.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
DatetimeΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡³πŸ‡±Netherlands ifrik

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΉAustria elek

    Thank you @mpdonadio, #3 made all clear for me. Don't know why I hat US-english instead of german in my browser settings. Well, I don't care or play around with those settings.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    I recently created πŸ“Œ Use ISO 8601 format in Authored on field date picker Active , which may be a duplicate of this issue ... but if it's possible, perhaps it might be simpler to use ISO 8601 format for dates represented by numbers (i.e. YYYY-MM-DD) and hard code it that way, to make dates less ambiguous? Adding possibly relevant issues.

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    The default date format were changed ( https://www.drupal.org/node/3467774 β†’ ) for Drupal 11.1.x. Basically they try to get away from date format using number only.

    Not sure if those date formats will have an impact for this issue as I did not install the 11.1.x branch yet.

    Personally, for area where we need a compact date shown, I prefer the ISO 8601 like YYYY-MM-DD.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Agreed that ISO 8601 is the nicest and most logical.

    But the date picker should use the short date format that the site has configured, for consistency and localisation.

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    But the date picker should use the short date format that the site has configured

    With the CR cited in #36, the Default short date is:

    Default short date 7 Aug 2024 - 13:55

    Is that format applicable to date pickers?

  • πŸ‡¬πŸ‡§United Kingdom joachim

    I mean the format set in core.date_format.short.yml, though it's true that could be configured by the user to be something that datepickers don't like.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    The default date format were changed ...

    @xmacinfo: I know, I am the one who created the issue and updated the code :-)

    That change does not affect the date picker in the form, as far as I can tell it's non-configurable ...

    Also, in my opinion, using letters for month in the date picker would be a bad idea, and another potentially confusing GUI design choice.

    Like I wrote -- and you both seem to agree -- it would be preferable to use ISO 8601 YYYY-MM-DD format for use cases with compact and number-only options, such as the date picker.

    The HTML Date format (from "Date and time formats" page) uses ISO 8601, in fact:

    HTML Date 2024-08-21

    Feel free to visit the issue I created, which proposes setting a Drupal date standard for "human readable"- and "number"-dates:

    #3467914: Define a standard for Date formats β†’

    If you both add your support to the proposal, we just need one more supporter to get ISO 8601 approved for "number"-dates (compact), and we could perhaps then do πŸ“Œ Use ISO 8601 format in Authored on field date picker Active , if you agree?

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    setting a Drupal date standard for "human readable"- and "number"-date

    I agree and I starting following the other two issues you mentioned.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Perfect, thanks @xmacinfo. It would be awesome to get date formats standardized in Drupal.

Production build 0.71.5 2024