2

We have a long date format in the transitional emails, such as "2015/12/01 00:00..." and I would like to show the date in a short format, like dd/mm/YYYY only. The email variable is:

{{var order.getCreatedAtFormated('long')}}

If I put "short" instead of "long", does it work?

6

Using short should work, take a look at Mage_Sales_Model_Order in /app/code/core/Mage/Sales/Model/Order.php

/**
 * Get formated order created date in store timezone
 *
 * @param   string $format date format type (short|medium|long|full)
 * @return  string
 */
public function getCreatedAtFormated($format)
{
    return Mage::helper('core')->formatDate($this->getCreatedAtStoreDate(), $format, true);
}
| improve this answer | |
3

You have to override /app/code/local/Mage/Sales/Model/Order.php, create a new function

public function getCreatedAtFormatedHideTime($format)
{
    return Mage::helper('core')->formatDate($this->getCreatedAtStoreDate(), $format, false);
}

So you can call it from mail template:

{{var order.getCreatedAtFormatedHideTime('short')}}

Output:

01/01/2000

| improve this answer | |
1

Look at getCreatedAtFormated method inside Mage_Sales_Model_Order class

/**
 * Get formated order created date in store timezone
 *
 * @param   string $format date format type (short|medium|long|full)
 * @return  string
 */
public function getCreatedAtFormated($format)
{
    return Mage::helper('core')->formatDate($this->getCreatedAtStoreDate(), $format, true);
}

public function getEmailCustomerNote()
{
    if ($this->getCustomerNoteNotify()) {
        return $this->getCustomerNote();
    }
    return '';
}
| improve this answer | |
  • It worked fine using {{var order.getCreatedAtFormated('short')}}, using "short" as parameter. However, the result was returned with the time and I would like to get just the date, dd/mm/YYYY, the time doesn't matter for the customer. But... it's already a beginning. – joaogdesigner Jan 6 '15 at 18:11

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.