The default date format on our site is set to dd/mm/yyyy (d/m/Y).

We have a date field that has the following validation:
- Must be on or after today
- Required
- In dd/mm/yyyy format

This works very well in all browsers except IE and Edge where the submitted date value has the month and day flipped and causes PHP validation error. A screenshot has been attached.

The export of the test form is here:

date:
  '#type': date
  '#title': Date
  '#default_value': today
  '#required': true
  '#min': today
  '#date_date_format': d/m/Y
CommentFileSizeAuthor
date-error.jpg58.9 KBDr Jason Guo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jason Guo created an issue. See original summary.

jrockowitz’s picture

Status: Active » Closed (won't fix)

This is a known issue with IE. @see http://caniuse.com/#feat=input-datetime

I recommend using the date list element.

maddentim’s picture

To those coming from a search engine to here. If you have an existing form with data in it and need to switch from date field to datelist field type, you can do it while preserving existing data. I first exported my config with 'drush cex'. Then I went into my yml file for each form and changed the type: date to type: datelist and imported it back in. Then I went into my setting for these fields and tuned it to my needs. I did this in a dev environment and imported all the changes to production and everyone was happy!