Skip to content

momentjs Library causing timezone shifting failure in date form element Ui Component #40372

@henriquebis2bis

Description

@henriquebis2bis

Preconditions and environment

  • Magento any version
  • Set the store timezone to America/Sao_Paulo for example

Steps to reproduce

  1. Set store timezone to America/Sao_Paulo
  2. Create date formElement in any ui component, example in category_form.xml:
Image
  1. Create the category attributes throught data patch, example:
    `$eavSetup->addAttribute(
    Category::ENTITY,
    'promotion_start_date',
    [
    'type' => 'datetime',
    'label' => 'Data Início da Promoção',
    'input' => 'date',
    'required' => false,
    'sort_order' => 100,
    'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
    'group' => 'PÁGINA DE PROMOÇÃO',
    'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class,
    ]
    );

     $eavSetup->addAttribute(
         Category::ENTITY,
         'promotion_end_date',
         [
             'type' => 'datetime',
             'label' => 'Data Fim da Promoção',
             'input' => 'date',
             'required' => false,
             'sort_order' => 110,
             'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
             'group' => 'PÁGINA DE PROMOÇÃO',
             'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class,
         ]
     );`
    
  2. Use magento 2 /rest/all/V1/categories/ API to set a date in this fields request example:
    { "category": { "id": {{categoryId}}, "custom_attributes": [ { "attribute_code": "promotion_start_date", "value": "2025-12-06 23:06:11" }, { "attribute_code": "promotion_end_date", "value": "2025-12-08 22:21:11" } ] } }

  3. Check in the category changed form in the admin area that the time will be UTC-2 instead of UTC-3, Brazil doesn't have summer time changes anymore, so we are always UTC-3, the momentjs library is not updated towards this, and it has been a while since we had this change

Expected result

Have the frontend component be loaded to -3 hours from UTC

Actual result

The frontend component is being loaded -2 hours from UTC

Additional information

No response

Release note

No response

Triage and priority

  • 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”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: ready for confirmationReported on 2.4.xIndicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions