Here is an extract from a book I have to hand (no I'm not the author). Its "PHP Developers Cookbook" published by SAMS, in case your interested...
I've not tested the code, but here goes.
<?php
$date1 = "03/03/2001";
$date2 = "10/08/2000";
list ($month1, $day1, $year1) = explode ("/", $date1);
list ($month2, $day2, $year2) = explode ("/", $date2);
$timestamp1 = mktime (0,0,0,$month1,$day1,$year1);
$timestamp2 = mktime (0,0,0,$month2,$day2,$year2);
$diff = ($timestamp1 > $timestamp2) ? ($timestamp1 - $timestamp2) : ($timestamp2 - $timestamp1);
print "The difference is\n";
print date ("Y", $diff) - 1970;
print "years, ". (date ("m", $diff) -1);
print "month and ". (date ("d",$diff) -1);
print "days.";
?>
Note to the site admin for this place, please make the message submission box a bit wider, as entering code is a bit of a nightmare :-)
Cheers,
Richard