DDC-1903: converting error of postgresql timestampz type #2396

Open
opened 2026-01-22 13:51:38 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 3, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user johnc:

Error message : Could not convert database value "2008-08-11 12:02:17.04286510" to Doctrine Type datetimetz. Expected format: Y-m-d H:i:sO ;

namespace Doctrine\DBAL\Types;

class DateTimeTzType extends Type{
...

public function convertToPHPValue($value, AbstractPlatform $platform)
{
    if ($value === null) {
        return null;
    }

    /****
     * modified by John Cho
     * postgresql timestampz "2008-08-11 12:02:17.042865</ins>10
     * need to remove .042865 part
     */

// if(strpos($value, ".") !== FALSE ){
// $arr = explode(".",$value);
// $arr2 = explode("",$arr[1]);
// $value = $arr[0]."
".$arr2[1];
// }
// for postgresql end

    $val = \DateTime::createFromFormat($platform->getDateTimeTzFormatString(), $value);
    if (!$val) {
        throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeTzFormatString());
    }
    return $val;
}

;

Originally created by @doctrinebot on GitHub (Jul 3, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user johnc: Error message : Could not convert database value "2008-08-11 12:02:17.042865<ins>10" to Doctrine Type datetimetz. Expected format: Y-m-d H:i:sO ; namespace Doctrine\DBAL\Types; class DateTimeTzType extends Type{ ... ``` public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } /**** * modified by John Cho * postgresql timestampz "2008-08-11 12:02:17.042865</ins>10 * need to remove .042865 part */ ``` // if(strpos($value, ".") !== FALSE ){ // $arr = explode(".",$value); // $arr2 = explode("<ins>",$arr[1]); // $value = $arr[0]."</ins>".$arr2[1]; // } // for postgresql end ``` $val = \DateTime::createFromFormat($platform->getDateTimeTzFormatString(), $value); if (!$val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeTzFormatString()); } return $val; } ``` ;
admin added the Bug label 2026-01-22 13:51:38 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2396