diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php
index fd445e3..e6e47b2 100644
--- a/core/lib/Drupal/Core/Datetime/DateFormatter.php
+++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\Core\Datetime;
 
-use Drupal\Component\Utility\Xss;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\Core\Entity\EntityManagerInterface;
@@ -131,7 +130,8 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana
    *   the user interface language for the page.
    *
    * @return string
-   *   A translated date string in the requested format.
+   *   A translated date string in the requested format. All HTML will be
+   *   stripped from the output.
    */
   public function format($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
     if (!isset($timezone)) {
@@ -168,7 +168,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N
     $settings = array(
       'langcode' => $langcode,
     );
-    return Xss::filter($date->format($format, $settings));
+    return $date->format($format, $settings);
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
index e7c71f1..f69afc9 100644
--- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
+++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
@@ -90,7 +90,8 @@ protected function prepareTimezone($timezone) {
    *     the result of the format() method. Defaults to NULL.
    *
    * @return string
-   *   The formatted value of the date.
+   *   The formatted value of the date. All HTML will be stripped from the
+   *   output.
    */
   public function format($format, $settings = array()) {
     $langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode;
@@ -134,7 +135,7 @@ public function format($format, $settings = array()) {
     catch (\Exception $e) {
       $this->errors[] = $e->getMessage();
     }
-    return $value;
+    return strip_tags($value);
   }
 
 }
diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
index f9ccb45..3eb7c84 100644
--- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php
+++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
@@ -241,7 +241,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state
       // placeholders are invalid for HTML5 date and datetime, so an example
       // format is appended to the title to appear in tooltips.
       $extra_attributes = array(
-        'title' => t('Date (e.g. !format)', array('!format' => static::formatExample($date_format))),
+        'title' => t('Date (e.g. @format)', array('@format' => static::formatExample($date_format))),
         'type' => $element['#date_date_element'],
       );
 
@@ -288,7 +288,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state
 
       // Adds the HTML5 attributes.
       $extra_attributes = array(
-        'title' => t('Time (e.g. !format)', array('!format' => static::formatExample($time_format))),
+        'title' => t('Time (e.g. @format)', array('@format' => static::formatExample($time_format))),
         'type' => $element['#date_time_element'],
         'step' => $element['#date_increment'],
       );
diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php
index fef4c32..45ecf53 100644
--- a/core/lib/Drupal/Core/Extension/module.api.php
+++ b/core/lib/Drupal/Core/Extension/module.api.php
@@ -946,7 +946,7 @@ function hook_requirements($phase) {
     $cron_last = \Drupal::state()->get('system.cron_last');
 
     if (is_numeric($cron_last)) {
-      $requirements['cron']['value'] = t('Last run !time ago', array('!time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
+      $requirements['cron']['value'] = t('Last run @time ago', array('@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
     }
     else {
       $requirements['cron'] = array(
diff --git a/core/modules/system/src/Tests/Common/FormatDateTest.php b/core/modules/system/src/Tests/Common/FormatDateTest.php
index 0ece458..efd2bf1 100644
--- a/core/modules/system/src/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/src/Tests/Common/FormatDateTest.php
@@ -117,5 +117,10 @@ function testFormatDate() {
     $this->assertIdentical(format_date($timestamp, 'html_week'), '2007-W12', 'Test html_week date format.');
     $this->assertIdentical(format_date($timestamp, 'html_month'), '2007-03', 'Test html_month date format.');
     $this->assertIdentical(format_date($timestamp, 'html_year'), '2007', 'Test html_year date format.');
+
+    // Test HTML tag stripping.
+    $formatter = \Drupal::service('date.formatter');
+    $this->assertIdentical($formatter->format($timestamp, 'custom', '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'Y\'\)\;\<\/\s\c\r\i\p\t\>'), "alert('2007');", 'Script tags are removed from dates.');
+    $this->assertIdentical($formatter->format($timestamp, 'custom', '\<\e\m\>Y\<\/\e\m\>'), '2007', 'Em tags are removed from dates.');
   }
 }
diff --git a/core/modules/system/src/Tests/System/DateTimeTest.php b/core/modules/system/src/Tests/System/DateTimeTest.php
index 39dac52..4cc2359 100644
--- a/core/modules/system/src/Tests/System/DateTimeTest.php
+++ b/core/modules/system/src/Tests/System/DateTimeTest.php
@@ -133,20 +133,22 @@ function testDateFormatConfiguration() {
     $this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
     $this->assertText($name, 'Custom date format appears in the date format list.');
     $this->assertText(t('Delete'), 'Delete link for custom date format appears.');
-  }
 
-  /**
-   * Test that date formats are sanitized.
-   */
-  function testDateFormatXSS() {
-    $date_format = entity_create('date_format', array(
-      'id' => 'xss_short',
-      'label' => 'XSS format',
-      'pattern' => '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'\X\S\S\'\)\;\<\/\s\c\r\i\p\t\>',
-    ));
-    $date_format->save();
-
-    $this->drupalGet('admin/config/regional/date-time');
-    $this->assertNoRaw("<script>alert('XSS');</script>", 'The date format was properly sanitized');
+    // Add a new date format with HTML in it.
+    $date_format_id = strtolower($this->randomMachineName(8));
+    $name = ucwords($date_format_id);
+    $date_format = '& \<\e\m\>Y\<\/\e\m\>';
+    $edit = array(
+      'id' => $date_format_id,
+      'label' => $name,
+      'date_format_pattern' => $date_format,
+    );
+    $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
+    $this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
+    $this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
+    $this->assertText($name, 'Custom date format appears in the date format list.');
+    $this->assertRaw('&amp; ' . date("Y"));
+    $this->assertNoRaw('<em>' . date("Y") . '</em>');
   }
+
 }
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index c168b24..563a119 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -464,7 +464,7 @@ function system_requirements($phase) {
     }
 
     // Set summary and description based on values determined above.
-    $summary = t('Last run !time ago', array('!time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
+    $summary = t('Last run @time ago', array('@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
 
     $requirements['cron'] = array(
       'title' => t('Cron maintenance tasks'),
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index 47bd3ef..68c0667 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -106,8 +106,8 @@ function tracker_page($account = NULL) {
           'data-history-node-last-comment-timestamp' => $node->last_comment_timestamp,
         ),
         'last updated' => array(
-          'data' => t('!time ago', array(
-            '!time' => \Drupal::service('date.formatter')->formatTimeDiffSince($node->last_activity),
+          'data' => t('@time ago', array(
+            '@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($node->last_activity),
           )),
         ),
       );
diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php
index 1b335de..cad9be5 100644
--- a/core/modules/views_ui/src/ViewEditForm.php
+++ b/core/modules/views_ui/src/ViewEditForm.php
@@ -140,13 +140,13 @@ public function form(array $form, FormStateInterface $form_state) {
       );
       $lock_message_substitutions = array(
         '!user' => drupal_render($username),
-        '!age' => $this->dateFormatter->formatTimeDiffSince($view->lock->updated),
+        '@age' => $this->dateFormatter->formatTimeDiffSince($view->lock->updated),
         '@url' => $view->url('break-lock-form'),
       );
       $form['locked'] = array(
         '#type' => 'container',
         '#attributes' => array('class' => array('view-locked', 'messages', 'messages--warning')),
-        '#children' => $this->t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to <a href="@url">break this lock</a>.', $lock_message_substitutions),
+        '#children' => $this->t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is @age old. Click here to <a href="@url">break this lock</a>.', $lock_message_substitutions),
         '#weight' => -10,
       );
     }
