PHP Help - Calculate Differences of Two Dates

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
// PHP Help - Calculate Differences of Two Dates
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

<?
//Purpose : Php function to find differences between two dates
//Programmer : Mohd Izzairi Yamin

function datedifferences($dformat, $endDate, $startDate)
{
$date_parts1=explode($dformat, $startDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
$dob=”05/15/1980″;

echo “Izzairi’s Birthday is ” . $dob . “, then today your age is approximately ” . round(datedifferences(”/”, date(”m/d/Y”, time()), $dob)/365, 0) . ” years.”;
?>


About this entry