3

I want to change the date format for admin in Sales->Order(view order)->Invoices tab in 24H format

enter image description here

I tried to find how this grid is rendered and i found(with template path hinth) that this table is rendered in vendor\magento\module-ui\view\base\ui_component\templates\listing\default.xhtml.

<div
    class="admin__data-grid-outer-wrap"
    data-bind="scope: '{{getName()}}.{{getName()}}'"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../../../../../Ui/etc/ui_template.xsd">
    <div data-role="spinner" data-component="{{getName()}}.{{getName()}}.{{spinner}}" class="admin__data-grid-loading-mask">
        <div class="spinner">
            <span/><span/><span/><span/><span/><span/><span/><span/>
        </div>
    </div>
    <!-- ko template: getTemplate() --><!-- /ko -->
</div>

And from here some KO js files are loaded. I am not god at KO js and I don't know how can I do this?

Does anyone know how can I change this date format?

1 Answer 1

1

To change any date to 24 format in SALES menu:

override /vendor/magento/module-sales/view/adminhtml/ui_component/ xml that you need and add:<item name="dateFormat" xsi:type="string">MMM dd, YYYY, HH:mm:ss </item> for the date filed.

As an example:

  <column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">dateRange</item>
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
                    <item name="dataType" xsi:type="string">date</item>
                    <item name="label" xsi:type="string" translate="true">Created</item>
                    <item name="dateFormat" xsi:type="string">MMM dd, YYYY, HH:mm:ss </item>
                </item>
            </argument>
        </column>
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.