Skip to content

Cannot create Customer with Date of Birth in Magento 2.1 (en_GB locale) #6323

@JacobDrummond

Description

@JacobDrummond

Environment

  1. Apache 2.4.17
  2. MySQL 5.0.11-dev
  3. PHP 5.6.15
  4. Magento 2.1.0

Steps to reproduce

  1. In System > All Users > User > [You], set the interface locale to English (United Kingdom):
    blog-3
  2. Create a new customer. Make sure to fill in Date of Birth field:
    c-1
  3. Save Customer

Expected result

  1. Customer saves without error

Actual result

  1. "Invalid date" exception thrown:
    c-2
  2. Trying to save the new customer again results in a JS validation error:
    c-3

Cause

  • The culprit is Date::inputFilter()
  • In my case, Date::inputFilter() accepts 08/24/2016 and returns 0,8/2,4/2,016
  • 0,8/2,4/2,016 is not a real date in any locale, causing an exception to be thrown.

General locale issues in Magento 2.1

  • Changing admin locale from en_US to en_GB causes PHP date formats to change, but not JS date formats.
  • In the above example, the JS datepicker populated the field with 08/24/2016, despite the entire UI being in en_GB.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions