I have the following script which shows me 5 recent invoices as below:
<?php
$year = (int)(substr($invoice['Invoice']['invoice_date'], 0, -6));
$month = (int)(substr($invoice['Invoice']['invoice_date'], 5, -3));
?>
<?php if($count < 5) : ?>
This now shows the 5 latest invoices, no matter which month they are due. How can I tweak / alter this snippet to showcase me the 5 invoices for the current month?
Why not to use cakephp time helper
.
<?php $year = $time->format('Y',$invoice['Invoice']['invoice_date']); ?>
<?php $month = $time->format('m',$invoice['Invoice']['invoice_date']); ?>
And for your latest record of this month try below solution.
<?php
$this->Invoice->find('all', array
(
'conditions'=> array('DATE_FORMAT(Invoice.invoice_date,"%m") = "'.date("m").'"')
));