magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Date format not respected in date ui component

Open ioweb-gr opened this issue 1 year ago • 11 comments

Preconditions and environment

  • 2.4.6-p5

Steps to reproduce

I've created a ui component form

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">sync_documents_form.sync_documents_form_data_source</item>
        </item>
        <item name="label" xsi:type="string" translate="true">Sync Documents</item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <settings>
        <buttons>
            <button name="save" class="Mv\CliDocumentImporter\Block\Adminhtml\SyncDocuments\Button\Submit"/>
        </buttons>
        <namespace>sync_documents_form</namespace>
        <dataScope>data.general</dataScope>
        <deps>
            <dep>sync_documents_form.sync_documents_form_data_source</dep>
        </deps>
    </settings>
    <dataSource name="sync_documents_form_data_source" component="Magento_Ui/js/form/provider">
        <settings>
            <submitUrl path="clidocumentimporter/customer/syncsubmit"/>
        </settings>
        <dataProvider class="Mv\CliDocumentImporter\Ui\DataProvider\SyncDocuments" name="sync_documents_form_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <fieldset name="general">
        <settings>
            <label translate="true">General</label>
        </settings>
        <field name="id" formElement="hidden">
            <settings>
                <dataType>text</dataType>
                <dataScope>id</dataScope>
            </settings>
        </field>
        <field name="customer_ids" formElement="hidden">
            <settings>
                <dataType>text</dataType>
                <label translate="true">Customers</label>
                <dataScope>customer_ids</dataScope>
            </settings>
        </field>
        <field name="date_from" formElement="date">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="options" xsi:type="array">
                        <item name="showsTime" xsi:type="boolean">false</item>
                        <item name="inputDateFormat" xsi:type="string">y-MM-dd</item>
                        <item name="outputDateFormat" xsi:type="string">y-MM-dd</item>
                        <item name="pickerDateTimeFormat" xsi:type="string">y-MM-dd</item>
                    </item>
                </item>
            </argument>
            <settings>
                <dataType>timestamp</dataType>
                <label translate="true">Date From</label>
                <dataScope>date_from</dataScope>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                    <rule name="validate-date" xsi:type="boolean">true</rule>
                </validation>
                <notice translate="true">Enter the starting date to sync from</notice>
            </settings>
        </field>
    </fieldset>
</form>

But I notice that the date field appears with the wrong date format.

I want to force display and input value as the equivalent of php's 'Y-m-d' format.

However no matter what I put in the config options https://developer.adobe.com/commerce/frontend-core/ui-components/components/date/

the display is like this

image

And the input value is passed as seen in the screenshot.

Expected result

My field renders with the appropriate date format.

Actual result

The field appears in the wrong format.

Additional information

No response

Release note

No response

Triage and priority

  • [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

ioweb-gr avatar Sep 26 '24 06:09 ioweb-gr

Hi @ioweb-gr. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

m2-assistant[bot] avatar Sep 26 '24 06:09 m2-assistant[bot]

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • [ ] 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • [ ] 5. Add label Issue: Confirmed once verification is complete.
  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Sep 27 '24 06:09 m2-assistant[bot]

Hello @ioweb-gr,

Thank you for the report and collaboration!

Verified this issue on 2.4-develop, and it's reproduced. When creating a ui component of date field, the date format is not being changed as specified.

Please take a look at the screenshot: Even though the date format is specified as y-MM-dd the default format is rendered. image

Hence confirming this.

Please find the module used to reproduce this issue. I39218V.zip

Thank you.

engcom-November avatar Sep 27 '24 12:09 engcom-November

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-13174 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Sep 27 '24 12:09 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Sep 27 '24 12:09 m2-assistant[bot]

Additionally it's not just the presentation it's also the actual value passed

ioweb-gr avatar Sep 27 '24 13:09 ioweb-gr

@magento I am working on this

its-leofisher avatar Oct 04 '24 14:10 its-leofisher

Hi @its-leofisher! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

m2-assistant[bot] avatar Oct 04 '24 14:10 m2-assistant[bot]

@magento add to contributors team

its-leofisher avatar Oct 04 '24 14:10 its-leofisher

Hi @its-leofisher! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

m2-assistant[bot] avatar Oct 04 '24 14:10 m2-assistant[bot]

@magento I am working on this

its-leofisher avatar Oct 04 '24 14:10 its-leofisher

Hello,

I'm facing the same error. Has it been fixed ? Thanks

aamouri82 avatar Aug 27 '25 13:08 aamouri82

Hi @ioweb-gr,

Adobe Commerce Engineering team started working on this issue. We will reach out to you if we need more information and you will get notified once the issue is fixed. Please leave comments for any further questions. Thank you!

engcom-Bravo avatar Nov 11 '25 09:11 engcom-Bravo

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-13174 by the internal team Related commits:https://github.com/search?q=repo%3Amagento%2Fmagento2+AC-13174&type=commits

Based on the Jira ticket, the target version is 2.4.9-beta1.

Thank You!

engcom-November avatar Nov 26 '25 12:11 engcom-November