All, I've the next PHP code to find out the number of years apart two dates take presctiption my Wordpress page:

<?php
$date1 = new DateTime("2003-03-24");
$current_date = new DateTime(date("Y-m-d"));
$interval = $date1->diff($current_date);
echo $interval->y;
?>

I installed the Professional-PHP wordpress plugin for Wordpress to show this correctly. However, if I attempt and display my page I recieve the next error:

Fatal error: Call to undefined method DateTime::diff() in /home/person/test.website.com/wordpress-content/plug ins/professional-php/includes/runtime.php(42) : eval()'d code online 7

How do i get this work correctly? Thanks!

As stated within the manual, DateTime::Diff (and all sorts of the DateInterval functions) will come in PHP >= 5.3. only.

You should install that version, or look for a workaround that utilizes another group of functions. Here is definitely an example based on how to get this done while using old timestamp-based date functions.

I recall this some time back: How to calculate the difference between two dates using PHP?

With a few small changes it appears such as this:

function convert_number($number) { 
    $Gn = floor($number / 1000000);  /* Millions (giga) */ 
    $number -= $Gn * 1000000; 
    $kn = floor($number / 1000);     /* Thousands (kilo) */ 
    $number -= $kn * 1000; 
    $Hn = floor($number / 100);      /* Hundreds (hecto) */ 
    $number -= $Hn * 100; 
    $Dn = floor($number / 10);       /* Tens (deca) */ 
    $n = $number % 10;               /* Ones */ 

    $res = ""; 

    if ($Gn)
        $res .= convert_number($Gn) . " Million"; 
    if ($kn)    { 
        $res .= (empty($res) ? "" : " ") . 
        convert_number($kn) . " Thousand"; 
    } 

    if ($Hn) { 
        $res .= (empty($res) ? "" : " ") . 
        convert_number($Hn) . " Hundred"; 
    } 

    $ones = array("", "One", "Two", "Three", "Four", "Five", "Six","Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen","Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen","Nineteen"); 
    $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty","Seventy", "Eigthy", "Ninety"); 

    if ($Dn || $n)  { 
        if (!empty($res))
            $res .= " and "; 

        if ($Dn < 2) 
        $res .= $ones[$Dn * 10 + $n]; 
        else { 
            $res .= $tens[$Dn]; 

            if ($n) 

            $res .= "-" . $ones[$n]; 
        } 
    } 

    if (empty($res)) 
        $res = "zero"; 

    return $res; 
} 

function yearsFromNow ($date) {
    return convert_number(floor(abs(strtotime($date) - strtotime(date("Y-m-d"))) / (365*60*60*24)));
}

echo yearsFromNow("2007-03-24");
echo yearsFromNow("2009-06-26");

Output:

4
2

Number to letters function modified out of this site: http://www.phpro.org/examples/Convert-Numbers-to-Words.html