My server uses an older version of PHP, so I unfortunately can’t use the $datetime1->diff($datetime2) method.
I am currently using the following code, but it doesn’t really work:
$from = explode("-",date("Y-m-d",$recurring_invoices->start_date));
$to = explode("-",date("Y-m-d",$to_time));
$months = ($to[0]-$from[0])*12+$to[1]-$from[1];
It will calculate July 30th to June 1st as one whole month. It should only count dates from July 1st to June 1st as a whole month.
I noticed there was a MYSQL TIMESTAMPDIFF function, but I can’t seem to get that to work either.
$query = "SELECT TIMESTAMPDIFF(MONTH,'$recurring_invoices->start_date','$from_time')";
print_r($this->queryResult($query));
or
$query = "SELECT TIMESTAMPDIFF(MONTH, from_date, to_date) FROM agenda";
print_r($this->queryResult($query));
Your help is much appreciated!
I think this should work,
but it is untestednow tested and fixed: