Search code examples
phpdatepdffootertcpdf

How to insert the date in PDF with PHP


Hey guys me and my friend we are workin on a PDf we are searching and searching for a solution how to fix the date in the footer. So the problem is that we need the date at the bottom left and we don't know how to insert the date in the footer... so our company doesn't let us copy the code so sorry bout that.

thanks for any help though.


Solution

  • Just make use of this TCPDF documentation on Custom Footer.

     public function Footer() {
            $this->SetY(-15);
            $this->SetFont('helvetica', 'I', 8);
            // Setting Date ( I have set the date here )
            $tDate=date('l \t\h\e jS');
            $this->Cell(0, 10, 'Date : '.$tDate, 0, false, 'C', 0, '', 0, false, 'T', 'M');
        }
    

    EDIT :

    date('l \t\h\e jS'); //displays date something like Wednesday the 11th
    

    If you are looking for a date something like this March 10, 2001, 5:16 pm , you can use this way $tDate = date("F j, Y, g:i a");

    For more info , check this PHP Date Manual