dateTime problem

Giganews Newsgroups
Subject: dateTime problem
Posted by:  bill (nobody@spamcop.net)
Date: Wed, 09 Sep 2009

Here is the code, it is located within a class
public function fPtAge($ptNum)  { // return pt age
  $sql = "select dob from ptInfo WHERE ptNum = '$ptNum' limit 1";
  $result = mysql_query( $sql, $this->connection) or
die(mysql_error()) ;
  $row = mysql_fetch_array($result)    ;
  $oDT = new DateTime(); //Sets the object to now
  $oDTDiff = $oDT->diff(new DateTime($row['dob'] ));
var_dump($oDTDiff);
echo 'Days of difference: $oDTDiff->days';
  return ($oDTDiff->days/365.25);
  } //return pt age

generates the error:
Fatal error: Call to undefined method DateTime::diff() in
/var/www/MP2010-v2/classes/cPatients.php on line 106

line 106 is:
  $oDTDiff = $oDT->diff(new DateTime($row['dob'] ));

PHP Version: 5.2.6-3ubuntu4.2

Date/Time is enabled

Anyone see what is wrong ?

bill

Replies