cancel
Showing results for 
Search instead for 
Did you mean: 

Date Format by UI component shows wrong date of birth

Date Format by UI component shows wrong date of birth

I have created one new customer attribute of date-of-birth for that I have added it in checkout page by extending LayoutProcessor's public function

afterProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $subject, array $jsLayout){
$customField1 = [
            'component' => 'Magento_Ui/js/form/element/abstract',
            'config' => [
                // customScope is used to group elements within a single form (e.g. they can be validated separately)
                'customScope' => 'shippingAddress.custom_attributes',
                'customEntry' => null,
                'template' => 'ui/form/field',
                'elementTmpl' => 'ui/form/element/date',
                'options' => [
                    'changeYear'=> true,
                    'changeMonth'=> true,
                    'yearRange' => '-120y:c+nn',
                    'maxDate' => '-1d'
                ],
            ],
            'dataScope' => 'shippingAddress.custom_attributes.dob',
            'provider' => 'checkoutProvider',
            'validation' => [
                'required-entry' => false
            ],
            'options' => [],
            'filterBy' => null,
            'customEntry' => null,
            'visible' => true,
            'disabled' => $disabled,
            'value' => "11/6/1997" // value field is used to set a default value of the attribute 
        ];
}

But on frontend I can see like this :

Screenshot 2020-05-12 at 9.00.46 PM.png

PS : I am using Magento Enterprise Edition.

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !