[BUGFIX] Convert date objects to string in SaveToDatabase finisher
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Finishers / SaveToDatabaseFinisher.php
index f37b9d4..1e88a41 100644 (file)
@@ -250,7 +250,11 @@ class SaveToDatabaseFinisher extends AbstractFinisher
                 }
             } elseif (is_array($elementValue)) {
                 $elementValue = implode(',', $elementValue);
+            } elseif ($elementValue instanceof \DateTimeInterface) {
+                $format = $elementsConfiguration[$elementIdentifier]['dateFormat'] ?? 'U';
+                $elementValue = $elementValue->format($format);
             }
+
             $databaseData[$elementsConfiguration[$elementIdentifier]['mapOnDatabaseColumn']] = $elementValue;
         }
         return $databaseData;