How to get order time in Magento?

I am trying to rewrite my PDF invoices in Magento. How can I display the created time without an order date?

I am preparing the insertOrder () class in /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php.

$page->drawText(Mage::helper('core')->formatDate($order->getCreatedAtStoreDate(), 'short', false), 100, 100, 'UTF-8');

shows only time combined with date.

+5
source share
1 answer

One way to display only the time part is as follows:

$sTime = Mage::app()
    ->getLocale()
    ->date(strtotime($order->getCreatedAtStoreDate()), null, null, false)
    ->toString('H:m:s');

$page->drawText($sTime, 100, 100, 'UTF-8');

Magento locale uses a modified class Zend_Datefor date and time operations.

Refer to the toString()method app/code/core/Zend/Date.phpfor parameter information.

+4
source

All Articles