コード例 #1
0
ファイル: TimePointType.php プロジェクト: rouffj/timemachine
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     $dtime = \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value);
     if (!$dtime) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return TimePointFactory::fromDateTime($dtime);
 }
コード例 #2
0
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof DateTime) {
         return $value;
     }
     $val = DateTime::createFromFormat($platform->getDateTimeTzFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeTzFormatString());
     }
     return $val;
 }
コード例 #3
0
ファイル: DateType.php プロジェクト: pscheit/psc-cms
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     $val = \Psc\DateTime\Date::parse($platform->getDateFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString());
     }
     return $val;
 }
コード例 #4
0
ファイル: DateTimeTzType.php プロジェクト: pasinter/redis-ohm
 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value)
 {
     if (empty($value)) {
         return null;
     } elseif ($value instanceof \DateTime) {
         return $value;
     }
     $val = \DateTime::createFromFormat('c', $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this);
     }
     return $val;
 }