Steps to reproduce

  • Add a date range field to a content type
  • Set Date type to "Date and time"
  • Leave the required field to be blank.
  • Set default start and end dates to - none -
  • Create a new content item
  • Fill only the date, not the time on one of the date range fields e.g. "Start date"
  • Click save.

Date range field error messages

Testing the new date range field, after saving the node I get the error: "The Start date is invalid. Please enter a date in the format 2016-10-06 11:45:44".

What it should do

Say that the time is missing in the error at the top.
Say that the time is missing on the item itself.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

taote created an issue. See original summary.

cilefen’s picture

Component: field system » datetime.module

What sort of date did you enter? Is the field configured for date and time (the default)?

mpdonadio’s picture

Status: Active » Postponed (maintainer needs more info)

Also, what browser are you using?

taote’s picture

The value was entered using the pop up calendar. The field is configured for date and time. The browser is Chrome for Mac.

mpdonadio’s picture

This is really weird. Does the same thing happen with normal datetime fields and explicitly setting the created date on nodes?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Chi’s picture

For me this happens when time sub field is empty.

jhedstrom’s picture

For me this happens when time sub field is empty.

For non-required fields, that is exactly what happens.

For required fields, this can't happen (assuming use of a browser that respects client-side validation)

We could potentially add a states item to the time field that requires itself if the date portion is filled out?

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

firfin’s picture

Still an issue on D8.4.2 , tested with firefox 56 for linux en chrome (current) for mac.
But only if I don't fill out the AM/PM bit of the element. Don't know why that is there though, All my date and time formats are 24 hour ones

firfin’s picture

Status: Postponed (maintainer needs more info) » Active

Hoping this is enough info.

mpdonadio’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs tests

If this is still a bug, then we need a test to demonstrate it. However, it sounds like the general problem is #2646454: Change the date format for the form display, which is the confusing with using the HTML5 input elements.

skorasaurus’s picture

I'm also experiencing this but I haven't figured out the specific circumstances that trigger this; but the error message that accompanies it is:

Warning: DateTime::createFromFormat() expects parameter 2 to be string, array given in Drupal\Component\Datetime\DateTimePlus::createFromFormat() (line 220 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Roy of Cranberry’s picture

FileSize
127.34 KB

I have 4 sites on Drupal 8.7.2. All use the Date and Time widget to set date and time fields in the mm/dd/yyyy hh:mm:ss am/pm style, I have been using this for quite a while. I was contacted by a Mac user who could not submit a form because of an error message for the required time and date fields. These fields work fine for me in Chrome and Firefox on Windows 7 and on Android. She is using:

Apple iMac macOS Mojave Version 10.14.3. Browser Firefox Quantum version 65.0.1(64-bit) (from the last time she couldn't submit a form and I think we submitted it for her manually). She has probably updated Firefox since the March 29, 2019 issue and it may be a later version now. She also tried using Safari on the same machine and gets the same result. It sounds more like a Mac problem than a browser problem to me.

Below is her complaint:

"I can't get it to send because of the start and end date info. You have two cells for the dates. But I have only one date for start and one date for end. I tried to send the form with just those dates and it comes back saying I have to fill in that second cell. But with what? What else needs to go into those second cells?"

In response to that, I emailed her the attached image and gave her my number in case that didn't help.

help graphic

Keep in mind, this image is just me trying to duplicate what I thought was her problem and give some pointers.

It did not help and I spoke with her on the phone this afternoon. Where I see a date field with mm/dd/yyyy, she sees a blank field. When she clicks into the date field, the pop up calendar lets her pick a date and that part is fine. As for the time field, it is apparently not marked as a time field for her and all she sees is a blank box with no idea what to put in it. I didn't fully realize her dilemma and have her try the correct format. She tried to use the correct format from my example, but I don't know if she misformatted it or if it just doesn't work at all.

While she was on the phone today and in the interest of letting her conduct the business she needed to conduct, I switched the field widget from the nicer "Date and time" widget to the not quite as nice "Select list". She was able to complete and submit the form that way. It is not as nice to look at and the year selector starts at 1900 of all years, rather than the current year resulting in excessive scrolling to get to 2019. I then set default dates to avoid that hefty scroll, but for a required field, as these are, that opens the door to someone not changing the default field data, negating the purpose of a required field, resulting in the need for follow-up to get the correct data.

Subsequently, I created a test form with 3 date time fields. The first date uses the "Select list" widget. The second uses the "Date and time" widget with no default and the third field uses "Date and time" with a default date/time. I sent her a link to this test form to try out with a format example to see if she can submit it that way. The form is also available to the public for anyone here who would like to try it out. It does have a 25-second honeypot on it so take your time.

The form is available here: https://ctcchest.org/contact/date-time-widget

I wonder if she needs to enable some functionality in her browsers? Does anyone know what "Date and time" requires of the browser that "Select list" doesn't? In 3 years, this is the first person I've seen with this issue. I'm starting to get the feeling this is a browser configuration problem versus a Drupal problem.

It didn't help that the form did not mention the word "time", which was corrected today, along with supplying an example format of date and time.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
Amber Himes Matz’s picture

Thanks for reporting this issue. We rely on issue reports like this one to resolve bugs and improve Drupal core.

As part of the Bug Smash Initiative, we are triaging issues that are marked "Postponed (maintainer needs more info)". This issue was marked "Postponed (maintainer needs more info)" back in November 2017.

There has been no activity here for 3 years.

Since we need more information (steps to reproduce or a test) to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after 3 months.

Thanks!

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jaime@gingerrobot.com’s picture

Version: 9.4.x-dev » 10.1.x-dev
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs steps to reproduce +DrupalSouth, +widget, +error message, +Usability
FileSize
273.22 KB

I've updated this ticket with steps to reproduce. There is a ticket in for Usability for Date data types [2897397]. We probably need the best practices sorted out but for now perhaps we could just save the data as midnight or improve the error messages.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.