如何在 Magento 中获取订单时间?

Posted

技术标签:

【中文标题】如何在 Magento 中获取订单时间?【英文标题】:How to get Order Time in Magento? 【发布时间】:2012-09-14 11:06:19 【问题描述】:

我正在尝试在 Magento 中重写我的 PDF 发票。如何在没有订单日期的情况下显示创建时间?

我正在 /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php 中准备类 insertOrder()。

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

仅结合日期显示时间。

【问题讨论】:

【参考方案1】:

仅显示时间部分的一种方法是:

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

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

Magento 的语言环境使用修改后的 Zend_Date 类进行日期/时间操作。

参数信息见app/code/core/Zend/Date.phptoString()方法。

【讨论】:

以上是关于如何在 Magento 中获取订单时间?的主要内容,如果未能解决你的问题,请参考以下文章