Browse Source

Fix DateType not clearing time for DateTimeImmutable

othercorey 4 years ago
parent
commit
c07dee5c71
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/Database/Type/DateType.php

+ 3 - 2
src/Database/Type/DateType.php

@@ -15,6 +15,7 @@
 namespace Cake\Database\Type;
 
 use DateTime;
+use DateTimeImmutable;
 
 /**
  * Class DateType
@@ -80,8 +81,8 @@ class DateType extends DateTimeType
     public function marshal($value)
     {
         $date = parent::marshal($value);
-        if ($date instanceof DateTime) {
-            $date->setTime(0, 0, 0);
+        if ($date instanceof DateTime || $date instanceof DateTimeImmutable) {
+            $date = $date->setTime(0, 0, 0);
         }
 
         return $date;