- round: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
function dateDiff($start, $end) {
$start = strtotime($start);
$end = strtotime($end);
$diff = $end - $start;
return round($diff / 86400);
}
$d1 = new DateTime('2010-01-30');
$d2 = new DateTime(date(Y-m-d));
$diff = $d2->diff($d1);
echo $diff->y;