代码之家  ›  专栏  ›  技术社区  ›  Alisinasyon

如何在Magento获得订单时间?

  •  5
  • Alisinasyon  · 技术社区  · 13 年前

    我正在尝试在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 回复  |  直到 13 年前
        1
  •  4
  •   Jürgen Thelen    13 年前

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

    $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 用于日期/时间操作的类。

    请参阅 toString() 方法 app/code/core/Zend/Date.php 参数信息。