0

I have added a new field in the order process called desired_deliver_date.

I can get the value of this field into the email by putting

 {{var order.getDesiredDeliveryDate()}}

However the date format is YYYY-mm-dd

Can someone advise whats the best way to format the date so its dd/mm/YYYY ?

1

Add to the order object real function getDesiredDeliveryDate that will format the date. Like

public function getDesiredDeliveryDate($format)
{
    return Mage::helper('core')->formatDate($this->getDesiredDeliveryDate(), $format, true);
}
6
  • Thanks sorry but where exactly would I put that function?
    – Goose84
    Sep 10 '14 at 13:12
  • You need to rewrite the order object or copy it to local folder. See for example inchoo.net/magento/how_to_override_magento_model_classes
    – Amasty
    Sep 10 '14 at 13:23
  • Do you mean copy /app/code/core/Mage/Sales/Model/Order.php to local folder and put the function in there?
    – Goose84
    Sep 10 '14 at 13:28
  • Yes, it's not a super best practice, but you can do it. It's easy and fast solution.
    – Amasty
    Sep 10 '14 at 13:35
  • Curious about the difference between "best practice" and "super best practice". =)
    – pspahn
    Sep 10 '14 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.