Example #1
0
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof DateTime) {
         return $value;
     }
     $val = DateTime::createFromFormat('!' . $platform->getDateFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString());
     }
     return $val;
 }
Example #2
0
 public function testCreateFromFormat()
 {
     $dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2016-05-16 14:09:10');
     self::assertInstanceOf(DateTime::class, $dateTime);
     self::assertEquals('2016-05-16T14:09:10+02:00', (string) $dateTime);
 }