Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 the date of a Order?

I am preparing the class insertOrder() 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 the time in combination with date.

like image 462
Alisinasyon Avatar asked Oct 06 '22 13:10

Alisinasyon


1 Answers

One way to display the time part only would be this:

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

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

Magento's locale uses a modified Zend_Date class for date/time operations.

See the toString() method of app/code/core/Zend/Date.php for parameter infos.

like image 98
Jürgen Thelen Avatar answered Oct 10 '22 03:10

Jürgen Thelen