How to add time to date in template?

I need time added to date in Invoices due to law legislation. I see there is a column in invoices table invoice_time_created with time. How can I add it to my pdf template? Tried to add it like in bellow but it is not working. I guess date_from_mysql function doesn’t supported.

 <div class="invoice-details clearfix">
        <table>
            <tr>
                <td><?php echo trans('invoice_date') . ':'; ?></td>
                <td><?php echo date_from_mysql($invoice->invoice_date_created, true); echo date_from_mysql($invoice->invoice_time_created, true); ?></td>
            </tr>
            <tr>

Open the Invoice controller
Find the function that will call the file you want to make the change to

In the data that gets sent to the view file the invoice_date_created is missing.

You need to add it.

$this->layout->set(
            [
                'invoice' => $invoice,
                'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(),
                'invoice_id' => $invoice_id,
... here somewhere

It depends on whether you want to add the date in the “view” or while editing /creating the invoice

The changes in the view file, are great, don’t change that

I have been using IP for 10 years, I am on v.1.4.2 version. I had to use it just for Quotes as the Invoice has to go through some customizations so I gave up in the end because I am noob with PHP. I did template it to my visual likeing and managed to get through with custom fields. But writing manually the invoices is a time waster so now I have deployed the fresh version from scratch and want to template it again.

My invoice numbering is like this 1-A-1. The first number changes incrementaly on every invoice, -A-1 part is fixed. When its new year, it has to start again from 1-A-1. I must not add any more numbers for example a year. That is the problem as on the next year, system will not allow using again 1-A-1 as it is allready used. I can probably fix that by adding a {{{year}}} in invoice and then hiding it with code in PDF temaplate so the end user gets pdf with 1-A-1 and no year.

Second problem is that the invoice must have a time created beside date created. I see that you put invoice_time_created field in mysql table but is it not used in invoice section. You are mentioning invoice_date_created and that is working and present in pdf template by default. Can you help me with more details please how to send date_time_created to invoice? Where is invoice controller and what should I put exactly?

I could comment/delete the part in PDF template that is related to printing out date and just use custom fields and enter the date and time manually but this looks to me it can be done somehow in the code instead. So I do not have to do it manually every time.

I can probably fix that by adding a {{{year}}} in invoice and then hiding it with code in PDF temaplate so the end user gets pdf with 1-A-1 and no year.

Yep, give that a try

Can you help me with more details please how to send date_time_created to invoice? Where is invoice controller and what should I put exactly

It depends on whether you want that date while viewing the invoice or while creating / editing the invoice.

They are 2 different functions
Open https://github.com/InvoicePlane/InvoicePlane/blob/development/application/modules/invoices/controllers/Invoices.php

The functions you are looking for is view and form

At the end you’ll see something like this:
$this->layout->set(

^^^^ that sets lots of variables to your view.
You’ll either want to add a separate variable or You’ll want to edit this one
'invoice' => $invoice,

If you can let us know what you want to change, i’ll tell you where to change it

I have managed to replace the invoice numbering year in PDF buy replacing that part with empty string so that is done :slight_smile: As for date time created, I have added custom field, I will put time in that box so no problem. Tnx for support.