<?php
function dateDiff($dformat, $endDate, $beginDate)
{
$split_endDate=split(” “,$endDate );
$split_beginDate=split(” “,$beginDate );
$date_parts1=explode($dformat, $split_beginDate[0]);
$date_parts2=explode($dformat, $split_endDate[0]);
$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
return $days=$end_date – $start_date;
} //end of function
function yearcalculate($days)
{
$year=floor($days/365);
$monthday=$days%365;
$month=round($monthday/30);
if($year==0)
{
if($month==1)
{
$str=$month.” month”;
}
else if($month==0)
{
$str=”No experience”;
}
else
{
$str=$month.” month (s)”;
}
} //end of main if statement
else
{
if($year==1)
{
if($month==1)
{
$str=$year.” Year “.$month.” month”;
}
else if($month==0)
{
$str=$year.” Year”;
}
else
{
$str=$year.” Year “.$month.” month (s)”;
}
} //end of year=1 if statement
else
{
if($month==1)
{
$str=$year.” Year(s) “.$month.” month”;
}
else if($month==0)
{
$str=$year.” Year(s)”;
}
else
{
$str=$year.” Year(s)”.$month.” month (s)”;
}
}
} //end of main else statement
return $str;
} //end of yearcalculate function
$date1=”2010-10-27 00:00:00″;
$date2=”2011-01-25 00:00:00″;
$days=dateDiff(“-”, $date2, $date1);
echo $res=yearcalculate($days);
?>