Reputation: 1454
I need to format the date in an email template. The date gets included in the plain .html
email as follows:
Dispatch Date: {{var order.getShippingDate()}}
Is there any way I can format this date? I've tried just using the standard PHP date
function to format it to no avail.
Upvotes: 2
Views: 8929
Reputation: 43
Dispatch Date: {{var order.getShippingDate()|formatDateTime:F j, Y}}
Upvotes: -2
Reputation: 139
You can add block directive with custom template
{{block type='core/template' area='frontend' template='email/order/shipment/date.phtml' shipment=$shipment order=$order}}
and there format date by helper.
OR rewrite Filter which uses for parsing of templates and add your directive
/**
* Setup callbacks for filters
*
*/
public function __construct()
{
$this->_modifiers['date'] = array($this, 'modifierDate');
}
public function modifierEscape($value, $format='d/m/Y')
{
return Mage::helper('core')->formatDate($value,$format);
}
this is not tested code. just example.
Upvotes: 3
Reputation: 11382
strtotime any help? It can parse a data back to a unix timestamp, which is what date() expects as an input.
edit after comment:
You can try creating a custom version of app/code/core/Mage/Sales/Model/Order.php under the app/code/local folder (it goes here so magento updates don't overwrite it). It contains a method called getCreatedAtFormated - you could apply the same principle to the shipping data and see if that achieves what you need to do.
Upvotes: 3