Skip to content

Admin date of birth doesn't factor in user locale set #27027

Closed
@extroniks

Description

@extroniks

Preconditions (*)

  1. Magento 2.3.4 (but probably on previous versions also)
  2. Login to admin
  3. Have locale set to en_GB (UK) for the user

Steps to reproduce (*)

  1. Edit a customer
  2. Select a date of birth after 12th of a month this year

Expected result (*)

  1. Date of birth is valid, you can save the customer

Actual result (*)

  1. Validation error happens "The Date of Birth should not be greater than today" because instead of DD/MM/YYYY the date is treated as MM/DD/YYYY

Here is a small composer patch I wrote for this:

--- a/view/base/web/js/lib/validation/rules.js
+++ b/view/base/web/js/lib/validation/rules.js
@@ -1069,12 +1069,12 @@ define([
             $.mage.__('This link is not allowed.')
         ],
         'validate-dob': [
-            function (value) {
+            function (value, param, params) {
                 if (value === '') {
                     return true;
                 }

-                return moment(value).isBefore(moment());
+                return moment.utc(value, params.dateFormat).isSameOrBefore(moment.utc());
             },
             $.mage.__('The Date of Birth should not be greater than today.')
         ]
--
2.17.1

Metadata

Metadata

Assignees

Labels

Component: AdminComponent: CustomerFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReported on 2.3.4Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions