After upgrade to PHP 5.3 my application is returning DB2 columns with Timestamp type as "2010-12-15-10.23.22.716000". This is causing problem for PHP DateTime function , as it fails with
$time = new DateTime("2010-12-15-10.23.22.716000");
Failed to parse time string (2010-12-15-10.23.22.716000) at position 25 (0): Unexpected character
It seems its having a problem with too much accuracy in DB2 timestamp. Can I somehow force connection to change timestamp format with it is fetching data into?
I am connecting to database with db2_connect function like this:
$this->connection = db2_connect ( $config ['dsn'], $config ['username'], $config ['password'] );
Edit: I would like to use solution mentioned below, but its not working for me and on my system (AS400) it runs weird. I have: $timeRec = DateTime::createFromFormat('Y-m-d-h.i.s.u',$value);
$value = $timeRec->format('Y-m-d H:i:s');
$value = new DibiDateTime($value);
If I do var_dump($value) after ->format, correct string is returned, but if I try feed this string to DibiDateTime, that has:
public function __construct($time = 'now', DateTimeZone $timezone = NULL)
{
if ($timezone === NULL) {
parent::__construct($time);
}
}
then it fails with:
function format() on a non-object
Even when I checked before with var_dump($timeRec) is proper DateTime object.