Send 2 Diferent Date and Get Number of Days as Output

<?
function SafDateDiff($dformat, $endDate, $beginDate){ //send yyyy-mm-dd start and end get the number of days
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[1], $date_parts1[2],$date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2],$date_parts2[0]);
return
$end_date - $start_date;
}
?>