I want to change the purchase date format in the order information grid to match the image. Even if I change the locale setting to my country, it remains the same. How can I change it?
Hello @nixordaumnaea1
To change the date format on the order grid in Magento 2, you'll need to create a custom module and modify the existing code. Here are the general steps you can follow:
<?php namespace YourNamespace\YourModule\Block\Adminhtml\Sales\Order; use Magento\Backend\Block\Widget\Grid as WidgetGrid; class Grid extends WidgetGrid { protected function _prepareColumns() { $this->addColumn( 'created_at', [ 'header' => __('Created At'), 'index' => 'created_at', 'type' => 'datetime', 'format' => 'd-M-Y', // Specify your desired date format here ] ); parent::_prepareColumns(); } }
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Sales\Block\Adminhtml\Order\Grid" type="YourNamespace\YourModule\Block\Adminhtml\Sales\Order\Grid" /> </config>
Then, clear the Magento cache using:
php bin/magento cache:clean
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9