Date Function & Time Difference in PHP

Hello,

Hello,
Hi Patrick,
<?PHP
$date1 = new DateTime('2011-06-10');
$date2 = new DateTime("now");
$interval = $date1->diff($date2);
$years = $interval->format('%y');
$months = $interval->format('%m');
$days = $interval->format('%d');
if($years!=0){
$ago = $years.' year(s) ago';
}else{
$ago = ($months == 0? $days.' day(s) ago': $months.' month(s) ago');
}
echo $ago;
?>
If used on the same day, It will return all 0's in the format.
<?PHP
$date1 = new DateTime('2011-05-161');
$date2 = new DateTime("now");
$interval = $date1->diff($date2);
$diff = $interval->format('%y-%m-%d');
echo $diff; //Today, this will output 0-0-0
?>