diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php
index 55a2fb1a04..245c990df4 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Datetime\DateFormatterInterface;
@@ -106,14 +107,14 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $elements = parent::settingsForm($form, $form_state);
 
-    $form['future_format'] = [
+    $elements['future_format'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Future format'),
       '#default_value' => $this->getSetting('future_format'),
       '#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
     ];
 
-    $form['past_format'] = [
+    $elements['past_format'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Past format'),
       '#default_value' => $this->getSetting('past_format'),
@@ -140,8 +141,8 @@ public function settingsSummary() {
 
     $future_date = strtotime('1 year 1 month 1 week 1 day 1 hour 1 minute');
     $past_date = strtotime('-1 year -1 month -1 week -1 day -1 hour -1 minute');
-    $summary[] = $this->t('Future date: %display', ['%display' => $this->formatTimestamp($future_date)]);
-    $summary[] = $this->t('Past date: %display', ['%display' => $this->formatTimestamp($past_date)]);
+    $summary[] = $this->t('Future date: %display', ['%display' => $this->formatTimestamp($future_date)->__toString()]);
+    $summary[] = $this->t('Past date: %display', ['%display' => $this->formatTimestamp($past_date)->__toString()]);
 
     return $summary;
   }
@@ -154,7 +155,9 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
 
     foreach ($items as $delta => $item) {
       if ($item->value) {
-        $updated = $this->formatTimestamp($item->value);
+        $updated = [
+          '#markup' => $this->formatTimestamp($item->value)
+        ];
       }
       else {
         $updated = [
@@ -174,7 +177,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
    * @param int $timestamp
    *   A UNIX timestamp to format.
    *
-   * @return array
+   * @return FormattableMarkup
    *   The formatted timestamp string using the past or future format setting.
    */
   protected function formatTimestamp($timestamp) {
@@ -186,18 +189,14 @@ protected function formatTimestamp($timestamp) {
 
     if ($this->request->server->get('REQUEST_TIME') > $timestamp) {
       $result = $this->dateFormatter->formatTimeDiffSince($timestamp, $options);
-      $build = [
-        '#markup' => SafeMarkup::format($this->getSetting('past_format'), ['@interval' => $result->getString()]),
-      ];
+      $setting = $this->getSetting('past_format');
     }
     else {
       $result = $this->dateFormatter->formatTimeDiffUntil($timestamp, $options);
-      $build = [
-        '#markup' => SafeMarkup::format($this->getSetting('future_format'), ['@interval' => $result->getString()]),
-      ];
+      $setting = $this->getSetting('future_format');
     }
-    CacheableMetadata::createFromObject($result)->applyTo($build);
-    return $build;
+
+    return new FormattableMarkup($setting, ['@interval' => $result->getString()]);
   }
 
 }
