This kinda relates to Access DateTime->date in php but is actually something else. I have some php that gets a DateTime object from a SQL server. I Convert it using
echo $mydate->format('Y-m-d H:i:s');
so that its just a string or at least i think it is. (I even used explicit type casting to make sure).
here is that code,
} else {
echo "<br/>object ";
$dt = (string) $row[$column]->format('Y-m-d H:i:s');
$this->retVal["nonEmpty"] = true;
$this->retVal["value"] = (string) $dt;
echo $this->retVal["value"]; //Returns a string, no issue.
}
The problem occurs when the "string" is passed back out of the class.
$convert = new DataConv;
$convert->conv($newConnectionThree, $fieldNames[$cnt1][$cnt2]["Type"],$fieldNames[$cnt1][$cnt2]["Size"], $tableNames[$cnt1], $columnNames[$cnt1][$cnt2]);
$fieldNames[$cnt1][$cnt2]["Type"] = $convert->type;
$returned = $convert->retVal;
echo $returned["value"]; //Returns error "Catchable fatal error: Object of class DateTime could not be converted to string".
var_dump($returned["value"]); //Shows Datetime object.
Now its back to being a Datetime object. I don't see any reason for it to be converted back. I was just wondering if anyone has an answer for at least why this happens, but a solution would be helpful. Anything short of making that conversion outside of the class.