A function that calculates the difference between 2 dates.  It is very similar to the datediff function available in Visual Basic.

function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {

if (!$using_timestamps) {

$datefrom = strtotime($datefrom, 0);

$dateto = strtotime($dateto, 0);

}

$difference = $dateto – $datefrom; // Difference in seconds

switch($interval) {

case ‘yyyy’: // Number of full years

$years_difference = floor($difference / 31536000);

if [...]