2

I wish to get the order date from order id, to display in the success page. Please provide me a solution

1
  • Do you want to Order details by order id or increment id? – Suresh Chikani May 9 '18 at 13:34
4

Please used

$order->getCreatedAt();

you get created date.

0
0

Here is ready made free extension,Please check this link

https://github.com/navinbhudiya/magento2-order-details-on-success-page

0

You can directly get order detail in phtml by object manager

Note : You can not use directly object Manager, Second solution is as per Magento standard

First solution

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\Order')->load($orderId);

echo "<pre>";
print_r($order->getCreatedAt());
exit;

Second Solution Get order details by below code

public function __construct(
    \Magento\Sales\Model\OrderFactory $orderFactory
) {
    $this->_orderFactory = $orderFactory;
}

$order = $this->_orderFactory->create()->load($passOrderId);
echo "<pre>";
print_r($order->getCreatedAt());
exit;

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