
	
<?php
	function datediff($date_start, $date_end)
	{
		$diff = $date_end - $date_start;
	    list($tm, $td, $ty) = split("[-/]", $date_end);
	    list($bm, $bd, $by) = split("[-/]", $date_start);
	    
	    $ydiff = $ty - $by;
	    $mdiff = $tm - $bm;
	    $ddiff = $td - $bd;
	    
	    $months = ($ydiff * 12) + $mdiff;

		if ($ddiff < 0)
		{
			$months--;
			$calcmonth = $tm - 1;
			if ($calcmonth == 0) $calcmonth = 12;
			$numdays = cal_days_in_month(CAL_GREGORIAN, $calcmonth, $ty);
			$ddiff = $numdays - $bd + $td;
		}

		$weeks = floor($ddiff / 7);
		$days = $ddiff % 7;

		$r = array($months, $weeks, $days);
		return $r;

	}
		
	function albert_age()
	{
		$date_end = date("m-d-Y");  // Today's date
		$date_start = "3-21-2005";  // Albert's birthday
		list($albert_age_m, $albert_age_w, $albert_age_d) = datediff($date_start, $date_end);	
	
		$albert_text_d = "";
		$albert_text_w = "";
		$albert_text_m = "Albert is $albert_age_m months";
	
		if (($albert_age_w + $albert_age_d) == 0)
		{
			$albert_text_m = "Albert is exactly $albert_age_m months";
		}
		else
		{
			if ($albert_age_d > 0)
			{
				$albert_text_d = ", and $albert_age_d day";
				if ($albert_age_d > 1) $albert_text_d = $albert_text_d."s";
	
				if ($albert_age_w > 0) $albert_text_w = ", $albert_age_w weeks";
			}
			else
			{
				$albert_text_w = " and $albert_age_w week";
				if ($albert_age_w > 1) $albert_text_w = $albert_text_w."s";
			}
		}
	
		$t = $albert_text_m.$albert_text_w.$albert_text_d." old.";
		return $t;
	}	
?>

