I'm trying to find the difference between dates in years between the date stored in a MySQL database and today's date. I just simply want to know how many years are there between the two. So far I have a date stored in a MySQL database in this format:
YYYY-MM-DD
2009-05-31

I'm trying to extract it and then figure out how many years there are between that date and today's date so I figured I had to convert it to Unix so I did this

list($year, $month, $day) = split("-", $Row["RecordingDate"]);
    $date1 = mktime(0, 0, 0, $month, $day, $year);

I then wanted to figure out today's date

$date2 = mktime();

And then what do I do? First off am I doing this correct so far? Second how do I put together a formula to figure out the difference in years?

    Try something like:

    SELECT CAST(DATEDIFF(year1, year2) / 365 AS UNSIGNED) AS numYears

    although there is the issue that not every year has 365 days...

      This looks like an SQL statement. How would I utilize this in my code instead of what I'm doing?

        Is $Row not the result of a SQL query? I was suggesting you modify the SQL query.

          Yes it is but I think I found something else that may work:

          list($year, $month, $day) = split("-", $Row["RecordingDate"]);
              $sqldate = mktime(0, 0, 0, $month, $day, $year);
          $thedifference=mktime() - $sqldate;
          $daydifference = intval($thedifference / 60 / 60 / 24 / 7 / 52);
            Write a Reply...