1

I'm using EaDesgin/magento2-pdf-generator2 to format the customer's invoice. This works nice. But in this template I use the magento 2 variable {{var invoice.created_at}}, what gives me the ugly format 'yyyy-mm-dd h:i:s'.

I want to reformat this date. Maybe I could add a custom variable (not with backend, there I cannot use PHP functions), or a filter to invoice.created_at. Where can I do that?

1 Answer 1

3

I solved the problem by adding a new function to Model/Order/Invoice.php:

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

Then you can use {{var invoice.invoice_date}} to display the formatted date.

Tested with Magento 2.2.3 and EADesign Invoice PDF Generator 1.2.2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.