diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
index 49aff3f8fa217cf8492dc490991915aebf63b279..ad2a89f08cf9fb6fe00bb1bb0091003504cfbd35 100644
--- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
+++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
@@ -134,28 +134,31 @@ public function format($format, $settings = []) {
       // Call date_format().
       $format = parent::format($format, $settings);
 
-      // Translates a formatted date string.
-      $translation_callback = function ($matches) use ($langcode) {
-        $code = $matches[1];
-        $string = $matches[2];
-        if (!isset($this->formatTranslationCache[$langcode][$code][$string])) {
-          $options = ['langcode' => $langcode];
-          if ($code == 'F') {
-            $options['context'] = 'Long month name';
-          }
+      // $format will be NULL if there are any errors.
+      if ($format !== NULL) {
+        // Translates a formatted date string.
+        $translation_callback = function ($matches) use ($langcode) {
+          $code = $matches[1];
+          $string = $matches[2];
+          if (!isset($this->formatTranslationCache[$langcode][$code][$string])) {
+            $options = ['langcode' => $langcode];
+            if ($code == 'F') {
+              $options['context'] = 'Long month name';
+            }
 
-          if ($code == '') {
-            $this->formatTranslationCache[$langcode][$code][$string] = $string;
-          }
-          else {
-            $this->formatTranslationCache[$langcode][$code][$string] = $this->t($string, [], $options);
+            if ($code == '') {
+              $this->formatTranslationCache[$langcode][$code][$string] = $string;
+            }
+            else {
+              $this->formatTranslationCache[$langcode][$code][$string] = $this->t($string, [], $options);
+            }
           }
-        }
-        return $this->formatTranslationCache[$langcode][$code][$string];
-      };
+          return $this->formatTranslationCache[$langcode][$code][$string];
+        };
 
-      // Translate the marked sequences.
-      $value = preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', $translation_callback, $format);
+        // Translate the marked sequences.
+        $value = preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', $translation_callback, $format);
+      }
     }
     catch (\Exception $e) {
       $this->errors[] = $e->getMessage();
diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php
index bd4b46c2422d15f170b1ace286921650f5c87868..bbb1676d70e1041b7646e0a9acc8eede16e5918d 100644
--- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php
+++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php
@@ -338,6 +338,9 @@ public static function validateDatelist(&$element, FormStateInterface $form_stat
    *   Array of keys from the input array that have no value, may be empty.
    */
   protected static function checkEmptyInputs($input, $parts) {
+    // The object key does not represent an input value, see
+    // \Drupal\Core\Datetime\Element\Datelist::valueCallback().
+    unset($input['object']);
     // Filters out empty array values, any valid value would have a string length.
     $filtered_input = array_filter($input, 'strlen');
     return array_diff($parts, array_keys($filtered_input));