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
  • I have added Invoice date & time to create own field "invoice_creted_date" split by create_at. It is added in a grid with a format, but not display a formatted date in export data. So please help me how to do this thing ? Commented Aug 8, 2018 at 6:38
  • 1
    For future reference, the solution proposed by @alin is outdated as of 2.2, github.com/magento/magento2/blob/2.1/app/code/Magento/Sales/… vs github.com/magento/magento2/blob/2.2/app/code/Magento/Sales/… Commented Aug 22, 2018 at 14:46
  • To change it in 2.2, you can add a <dateFormat> node within the <settings> node Commented Aug 22, 2018 at 14:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.