You can use the
getdate()
function which returns an array containing all elements of the date/time supplied:
$diff = abs($endDate - $startDate);
$my_t=getdate($diff);
print("$my_t[year] years, $my_t[month] months and $my_t[mday] days");
If your start and end dates are in string format then use
$startDate = strtotime($startDateStr);
$endDate = strtotime($endDateStr);
before the above code