Magento – How to display only invoice created date in invoice template and format date

invoice

I want to display invoice created date in invoice e-mail template.
I am using {{var invoice.created_at}} to display invoice created date. But it displaying 2015-05-25 13:30:55 . I need to only display date as 25 JUL 2015. Please help me. Thanks in advance.

Best Answer

You can rewrite or copy the code from Mage/Sales/Model/Order/Invoice.php to local folder and add the below function

public function getInvoiceDate()
    {
        $createdAt = $this->getCreatedAt();
        $invoiceDate = date('d M Y', strtotime($createdAt));
        return $invoiceDate;
    }

In invoice email template, get the date as {{var invoice.getInvoiceDate()}}. Like this you can add any number of functions and get from email templates

Related Topic