<?php
$origin = new DateTime('2019-09-01');
$target = new DateTime('2020-08-01');
$interval = $origin->diff($target);
echo $interval->format('%m');
echo "<hr>";
$anfang = strtotime('2019-09-01');
$ende = strtotime('2020-08-31');
$monate = abs((date('Y', $ende) - date('Y', $anfang))*12 + (date('m', $ende) - date('m', $anfang)));
echo $monate;
?>
