diff --git a/lib/Doctrine/DBAL/Types/DateTimeType.php b/lib/Doctrine/DBAL/Types/DateTimeType.php index ee2475624..1aca8bab2 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -23,11 +23,13 @@ class DateTimeType extends Type public function convertToDatabaseValue($value, AbstractPlatform $platform) { - return $value->format($platform->getDateTimeFormatString()); + return ($value !== null) + ? $value->format($platform->getDateTimeFormatString()) : null; } public function convertToPHPValue($value, AbstractPlatform $platform) { - return \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value); + return ($value !== null) + ? \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value) : null; } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Types/DateType.php b/lib/Doctrine/DBAL/Types/DateType.php index 58cf54b26..29aee72ad 100644 --- a/lib/Doctrine/DBAL/Types/DateType.php +++ b/lib/Doctrine/DBAL/Types/DateType.php @@ -23,11 +23,13 @@ class DateType extends Type public function convertToDatabaseValue($value, AbstractPlatform $platform) { - return $value->format($platform->getDateFormatString()); + return ($value !== null) + ? $value->format($platform->getDateFormatString()) : null; } public function convertToPHPValue($value, AbstractPlatform $platform) { - return \DateTime::createFromFormat($platform->getDateFormatString(), $value); + return ($value !== null) + ? \DateTime::createFromFormat($platform->getDateFormatString(), $value) : null; } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Types/TimeType.php b/lib/Doctrine/DBAL/Types/TimeType.php index 8256a5570..e6e1b6882 100644 --- a/lib/Doctrine/DBAL/Types/TimeType.php +++ b/lib/Doctrine/DBAL/Types/TimeType.php @@ -31,7 +31,8 @@ class TimeType extends Type */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { - return $value->format($platform->getTimeFormatString()); + return ($value !== null) + ? $value->format($platform->getTimeFormatString()) : null; } /** @@ -41,6 +42,7 @@ class TimeType extends Type */ public function convertToPHPValue($value, AbstractPlatform $platform) { - return \DateTime::createFromFormat($platform->getTimeFormatString(), $value); + return ($value !== null) + ? \DateTime::createFromFormat($platform->getTimeFormatString(), $value) : null; } } \ No newline at end of file