diff --git a/core/modules/datetime/config/schema/datetime.schema.yml b/core/modules/datetime/config/schema/datetime.schema.yml
index 0718e04..1f043f9 100644
--- a/core/modules/datetime/config/schema/datetime.schema.yml
+++ b/core/modules/datetime/config/schema/datetime.schema.yml
@@ -30,10 +30,53 @@ field.formatter.settings.datetime_default:
     format_type:
       type: string
       label: 'Date format'
+    timezone_override:
+      type: string
+      label: 'Timezone override'
+    append_timezone:
+      type: boolean
+      label: 'Append timezone'
 
 field.formatter.settings.datetime_plain:
   type: mapping
   label: 'Datetime plain display format settings'
+  mapping:
+    timezone_override:
+      type: string
+      label: 'Timezone override'
+    append_timezone:
+      type: boolean
+      label: 'Append timezone'
+
+field.formatter.settings.datetime_custom:
+  type: mapping
+  label: 'Datetime plain display format settings'
+  mapping:
+    timezone_override:
+      type: string
+      label: 'Timezone override'
+    append_timezone:
+      type: boolean
+      label: 'Append timezone'
+    date_format:
+      type: string
+      label: 'Format string'
+      translatable: true
+      translation context: 'PHP date format'
+
+field.formatter.settings.datetime_time_ago:
+  type: mapping
+  label: 'Datetime time ago display format settings'
+  mapping:
+    future_format:
+      type: string
+      label: 'Future format string'
+    past_format:
+      type: string
+      label: 'Past format string'
+    granularity:
+      type: integer
+      label: 'Granularity'
 
 field.widget.settings.datetime_datelist:
   type: mapping
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php
new file mode 100644
index 0000000..2bb42c6
--- /dev/null
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php
@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeCustomFormatter.
+ */
+
+namespace Drupal\datetime\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Plugin implementation of the 'Custom' formatter for 'datetime' fields.
+ *
+ * @FieldFormatter(
+ *   id = "datetime_custom",
+ *   label = @Translation("Custom"),
+ *   field_types = {
+ *     "datetime"
+ *   }
+ *)
+ */
+class DateTimeCustomFormatter extends DateTimeFormatterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultSettings() {
+    return array(
+      'date_format' => DATETIME_DATETIME_STORAGE_FORMAT,
+    ) + parent::defaultSettings();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function viewElements(FieldItemListInterface $items) {
+    $elements = array();
+
+    foreach ($items as $delta => $item) {
+      $output = '';
+      if (!empty($item->date)) {
+        $date = $item->date;
+
+        if ($this->getFieldSetting('datetime_type') == 'date') {
+          // A date without time will pick up the current time, use the default.
+          datetime_date_default_time($date);
+        }
+        $this->setTimeZone($date);
+
+        $output = $date->format($this->getSetting('date_format'));
+      }
+      $elements[$delta] = [
+        '#markup' => $this->appendTimezone($output),
+        '#cache' => [
+          'contexts' => [
+            'timezone',
+          ],
+        ],
+      ];
+    }
+
+    return $elements;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $form = parent::settingsForm($form, $form_state);
+
+    $form['date_format'] = array(
+      '#type' => 'textfield',
+      '#title' => $this->t('Format string'),
+      '#description' => $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')),
+      '#default_value' => $this->getSetting('date_format'),
+    );
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = parent::settingsSummary();
+
+    $date = new DrupalDateTime();
+    $this->setTimeZone($date);
+    $summary[] = $this->appendTimezone($date->format($this->getSetting('date_format')));
+
+    return $summary;
+  }
+
+}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
index a7cb32a..ba470a0 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
@@ -14,11 +14,10 @@
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\Core\Field\FormatterBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
- * Plugin implementation of the 'datetime_default' formatter.
+ * Plugin implementation of the 'Default' formatter for 'datetime' fields.
  *
  * @FieldFormatter(
  *   id = "datetime_default",
@@ -28,7 +27,7 @@
  *   }
  * )
  */
-class DateTimeDefaultFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
+class DateTimeDefaultFormatter extends DateTimeFormatterBase implements ContainerFactoryPluginInterface {
 
   /**
    * {@inheritdoc}
@@ -103,11 +102,9 @@ public static function create(ContainerInterface $container, array $configuratio
    * {@inheritdoc}
    */
   public function viewElements(FieldItemListInterface $items) {
-
     $elements = array();
 
     foreach ($items as $delta => $item) {
-
       $formatted_date = '';
       $iso_date = '';
 
@@ -116,13 +113,13 @@ public function viewElements(FieldItemListInterface $items) {
         // Create the ISO date in Universal Time.
         $iso_date = $date->format("Y-m-d\TH:i:s") . 'Z';
 
-        // The formatted output will be in local time.
-        $date->setTimeZone(timezone_open(drupal_get_user_timezone()));
         if ($this->getFieldSetting('datetime_type') == 'date') {
           // A date without time will pick up the current time, use the default.
           datetime_date_default_time($date);
         }
-        $formatted_date = $this->dateFormat($date);
+        $this->setTimeZone($date);
+
+        $formatted_date = $this->formatDate($date);
       }
 
       // Display the date using theme datetime.
@@ -160,23 +157,28 @@ public function viewElements(FieldItemListInterface $items) {
    * @return string
    *   A formatted date string using the chosen format.
    */
-  function dateFormat($date) {
+  protected function formatDate($date) {
     $format_type = $this->getSetting('format_type');
-    return $this->dateFormatter->format($date->getTimestamp(), $format_type);
+    $timezone = $this->getSetting('timezone_override');
+    $output = $this->dateFormatter->format($date->getTimestamp(), $format_type, '', $timezone != '' ? $timezone : null);
+    return $this->appendTimezone($output);
   }
 
   /**
    * {@inheritdoc}
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
+    $form = parent::settingsForm($form, $form_state);
+
     $time = new DrupalDateTime();
     $format_types = $this->dateStorage->loadMultiple();
+    $options = [];
     foreach ($format_types as $type => $type_info) {
       $format = $this->dateFormatter->format($time->format('U'), $type);
       $options[$type] = $type_info->label() . ' (' . $format . ')';
     }
 
-    $elements['format_type'] = array(
+    $form['format_type'] = array(
       '#type' => 'select',
       '#title' => t('Date format'),
       '#description' => t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."),
@@ -184,16 +186,18 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
       '#default_value' => $this->getSetting('format_type'),
     );
 
-    return $elements;
+    return $form;
   }
 
   /**
    * {@inheritdoc}
    */
   public function settingsSummary() {
-    $summary = array();
+    $summary = parent::settingsSummary();
+
     $date = new DrupalDateTime();
-    $summary[] = t('Format: @display', array('@display' => $this->dateFormat($date, FALSE)));
+    $summary[] = t('Format: @display', array('@display' => $this->appendTimezone($this->formatDate($date))));
+
     return $summary;
   }
 
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
new file mode 100644
index 0000000..90e1afd
--- /dev/null
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
@@ -0,0 +1,113 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeFormatterBase.
+ */
+
+namespace Drupal\datetime\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\Core\Field\FormatterBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Component\Utility\SafeMarkup;
+
+/**
+ * Base class for 'DateTime Field formatter' plugin implementations.
+ */
+abstract class DateTimeFormatterBase extends FormatterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultSettings() {
+    return array(
+      'timezone_override' => '',
+      'append_timezone' => FALSE,
+    ) + parent::defaultSettings();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $form = parent::settingsForm($form, $form_state);
+
+    $form['timezone_override'] = array(
+      '#type' => 'select',
+      '#title' => $this->t('Timezone override'),
+      '#description' => $this->t('The timezone selected here, will always be used'),
+      '#options' => system_time_zones(TRUE),
+      '#default_value' => $this->getSetting('timezone_override'),
+    );
+
+    $form['append_timezone'] = array(
+      '#type' => 'checkbox',
+      '#title' => $this->t('Append timezone'),
+      '#description' => $this->t('Append the timezone used to render the date'),
+      '#default_value' => $this->getSetting('append_timezone'),
+    );
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = parent::settingsSummary();
+
+    $override = $this->getSetting('timezone_override');
+    if ($override != '') {
+      $replacements = array(
+        '@timezone' => $this->getSetting('timezone_override'),
+        '@appended' => $this->getSetting('append_timezone') ? $this->t('(Appended)') : '',
+      );
+      $summary[] = ($override != '') ? $this->t('Timezone: @timezone @appended', $replacements) : '';
+    }
+
+    return $summary;
+  }
+
+  /**
+   * Sets the current users or overridden timezone on a date.
+   *
+   * @param \Drupal\Core\Datetime\DrupalDateTime $date
+   *   A DrupalDateTime object.
+   */
+  protected function setTimeZone(DrupalDateTime $date) {
+    if ($this->getSetting('timezone_override') == '') {
+      $date->setTimeZone(timezone_open(drupal_get_user_timezone()));
+    }
+    else{
+      $date->setTimezone(timezone_open($this->getSetting('timezone_override')));
+    }
+  }
+
+  /**
+   * Appends the timezone used to render the date.
+   *
+   * Note: This function will only append the timezone if the 'append_timezone'
+   * setting is TRUE.
+   *
+   * @param string $rendered_date
+   *   A formatted date string.
+   *
+   * @return string
+   *   A formatted date string with the timezone appended if the
+   *   'append_timezone' setting is TRUE.
+   */
+  protected function appendTimezone($rendered_date) {
+    $timezone = $this->getSetting('timezone_override');
+    if ($timezone != '' && $this->getSetting('append_timezone')) {
+      return SafeMarkup::format('@rendered_date (@timezone)', array(
+        '@rendered_date' => $rendered_date,
+        '@timezone' => $timezone,
+      ));
+    }
+    else {
+      return $rendered_date;
+    }
+  }
+
+}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
index 3f68a7f..cee83f5 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
@@ -7,11 +7,10 @@
 
 namespace Drupal\datetime\Plugin\Field\FieldFormatter;
 
-use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Field\FieldItemListInterface;
 
 /**
- * Plugin implementation of the 'datetime_plain' formatter.
+ * Plugin implementation of the 'Plain' formatter for 'datetime' fields.
  *
  * @FieldFormatter(
  *   id = "datetime_plain",
@@ -21,29 +20,29 @@
  *   }
  *)
  */
-class DateTimePlainFormatter extends FormatterBase {
+class DateTimePlainFormatter extends DateTimeFormatterBase {
 
   /**
    * {@inheritdoc}
    */
   public function viewElements(FieldItemListInterface $items) {
-
     $elements = array();
 
     foreach ($items as $delta => $item) {
-
       $output = '';
       if (!empty($item->date)) {
-        // The date was created and verified during field_load(), so it is safe
-        // to use without further inspection.
         $date = $item->date;
-        $date->setTimeZone(timezone_open(drupal_get_user_timezone()));
-        $format = DATETIME_DATETIME_STORAGE_FORMAT;
+
         if ($this->getFieldSetting('datetime_type') == 'date') {
           // A date without time will pick up the current time, use the default.
           datetime_date_default_time($date);
           $format = DATETIME_DATE_STORAGE_FORMAT;
         }
+        else {
+          $format = DATETIME_DATETIME_STORAGE_FORMAT;
+        }
+        $this->setTimeZone($date);
+
         $output = $date->format($format);
       }
       $elements[$delta] = [
@@ -52,7 +51,7 @@ public function viewElements(FieldItemListInterface $items) {
             'timezone',
           ],
         ],
-        '#markup' => $output,
+        '#markup' => $this->appendTimezone($output),
       ];
     }
 
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php
new file mode 100644
index 0000000..21e627a
--- /dev/null
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php
@@ -0,0 +1,214 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter.
+ */
+
+namespace Drupal\datetime\Plugin\Field\FieldFormatter;
+
+use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Core\Datetime\DateFormatter;
+use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Plugin implementation of the 'Time ago' formatter for 'datetime' fields.
+ *
+ * @FieldFormatter(
+ *   id = "datetime_time_ago",
+ *   label = @Translation("Time ago"),
+ *   field_types = {
+ *     "datetime"
+ *   }
+ * )
+ */
+class DateTimeTimeAgoFormatter extends DateTimeFormatterBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The date formatter service.
+   *
+   * @var \Drupal\Core\Datetime\DateFormatter
+   */
+  protected $dateFormatter;
+
+  /**
+   * The date storage.
+   *
+   * @var \Drupal\Core\Entity\EntityStorageInterface
+   */
+  protected $dateStorage;
+
+  /**
+   * The current Request object.
+   *
+   * @var \Symfony\Component\HttpFoundation\Request
+   */
+  protected $request;
+
+  /**
+   * Constructs a DateTimeTimeAgoFormatter object.
+   *
+   * @param string $plugin_id
+   *   The plugin_id for the formatter.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
+   *   The definition of the field to which the formatter is associated.
+   * @param array $settings
+   *   The formatter settings.
+   * @param string $label
+   *   The formatter label display setting.
+   * @param string $view_mode
+   *   The view mode.
+   * @param array $third_party_settings
+   *   Third party settings.
+   * @param \Drupal\Core\Datetime\DateFormatter $date_formatter
+   *   The date formatter service.
+   * @param \Drupal\Core\Entity\EntityStorageInterface $date_storage
+   *   The date storage.
+   * @param \Symfony\Component\HttpFoundation\Request $request
+   *   The current request.
+   */
+  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatter $date_formatter, EntityStorageInterface $date_storage, Request $request) {
+    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
+
+    $this->dateFormatter = $date_formatter;
+    $this->dateStorage = $date_storage;
+    $this->request = $request;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultSettings() {
+    $settings = array(
+      'future_format' => '@time hence',
+      'past_format' => '@time ago',
+      'granularity' => 2,
+    ) + parent::defaultSettings();
+
+    // Timezones don't make sense for "ago" formats, so they should be removed.
+    unset($settings['timezone_override'], $settings['append_timezone']);
+
+    return $settings;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $plugin_id,
+      $plugin_definition,
+      $configuration['field_definition'],
+      $configuration['settings'],
+      $configuration['label'],
+      $configuration['view_mode'],
+      $configuration['third_party_settings'],
+      $container->get('date.formatter'),
+      $container->get('entity.manager')->getStorage('date_format'),
+      $container->get('request_stack')->getCurrentRequest()
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function viewElements(FieldItemListInterface $items) {
+    $elements = array();
+
+    foreach ($items as $delta => $item) {
+      $date = $item->date;
+      $output = '';
+      if (!empty($item->date)) {
+        if ($this->getFieldSetting('datetime_type') == 'date') {
+          // A date without time will pick up the current time, use the default.
+          datetime_date_default_time($date);
+        }
+        $output = $this->formatDate($date);
+      }
+      $elements[$delta] = array('#markup' => $output);
+    }
+
+    return $elements;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $form = parent::settingsForm($form, $form_state);
+
+    $form['future_format'] = array(
+      '#type' => 'textfield',
+      '#title' => $this->t('Future format string'),
+      '#default_value' => $this->getSetting('future_format'),
+      '#description' => $this->t('The format string for dates in the future. Use <em>@time</em> where you want the time to appear.'),
+    );
+
+    $form['past_format'] = array(
+      '#type' => 'textfield',
+      '#title' => $this->t('Past format string'),
+      '#default_value' => $this->getSetting('past_format'),
+      '#description' => $this->t('The format string for dates in the past. Use <em>@time</em> where you want the time to appear.'),
+    );
+
+    $form['granularity'] = array(
+      '#type' => 'number',
+      '#title' => 'Interval',
+      '#default_value' => $this->getSetting('granularity'),
+      '#description' => $this->t('How many time units should be shown in the "time ago" string.'),
+    );
+
+    // Timezones don't make sense for "ago" formats, so they should be removed.
+    unset($form['timezone_override'], $form['append_timezone']);
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = parent::settingsSummary();
+
+    $future_date = new DrupalDateTime('1 year 1 month 1 week 1 day 1 hour 1 minute');
+    $past_date = new DrupalDateTime('-1 year -1 month -1 week -1 day -1 hour -1 minute');
+    $summary[] = t('Future date: %display', array('%display' => $this->formatDate($future_date)));
+    $summary[] = t('Past date: %display', array('%display' => $this->formatDate($past_date)));
+
+    return $summary;
+  }
+
+  /**
+   * Creates a formatted date value as a string.
+   *
+   * @todo Refactor when https://www.drupal.org/node/2456521 is comitted.
+   *
+   * @param \Drupal\Core\Datetime\DrupalDateTime|object $date
+   *   A date object.
+   * @return string
+   *   A formatted date string using the chosen format.
+   */
+  protected function formatDate(DrupalDateTime $date) {
+    $granularity = $this->getSetting('granularity');
+    $interval = $this->request->server->get('REQUEST_TIME') - $date->getTimestamp();
+
+    if ($interval > 0) {
+      return SafeMarkup::format($this->getSetting('past_format'), ['@time' => $this->dateFormatter->formatInterval($interval, $granularity)]);
+    }
+    else {
+      // DateFormatter::formatInterval() assumes positive intervals, so negate
+      // it to force the calculation to work properly.
+      return SafeMarkup::format($this->getSetting('future_format'), ['@time' => $this->dateFormatter->formatInterval(-$interval, $granularity)]);
+    }
+  }
+
+}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
index 32d3668..dfe750e 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
@@ -43,12 +43,12 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
       $date = $items[$delta]->date;
       // The date was created and verified during field_load(), so it is safe to
       // use without further inspection.
-      $date->setTimezone(new \DateTimeZone($element['value']['#date_timezone']));
       if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) {
         // A date without time will pick up the current time, use the default
         // time.
         datetime_date_default_time($date);
       }
+      $date->setTimezone(new \DateTimeZone($element['value']['#date_timezone']));
       $element['value']['#default_value'] = $date;
     }
 
diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
index f3fcae1..72f8b49 100644
--- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php
+++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\datetime\Tests;
 
+use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\Core\Datetime\DrupalDateTime;
@@ -47,9 +48,18 @@ class DateTimeFieldTest extends WebTestBase {
    */
   protected $field;
 
+  /**
+   * {@inheritdoc}
+   */
   protected function setUp() {
     parent::setUp();
 
+    // Set an explicit site timezone, and disallow per-user timezones.
+    $this->config('system.date')
+      ->set('timezone.user.configurable', 0)
+      ->set('timezone.default', 'Asia/Tokyo')
+      ->save();
+
     $web_user = $this->drupalCreateUser(array(
       'access content',
       'view test entity',
@@ -103,9 +113,17 @@ function testDateField() {
     $this->assertFieldByXPath('//*[@id="edit-' . $field_name . '-wrapper"]/h4[contains(@class, "form-required")]', TRUE, 'Required markup found');
     $this->assertNoFieldByName("{$field_name}[0][value][time]", '', 'Time element not found.');
 
-    // Submit a valid date and ensure it is accepted.
+    // Build up a date in the UTC timezone.
     $value = '2012-12-31 00:00:00';
-    $date = new DrupalDateTime($value);
+    $date = new DrupalDateTime($value, 'UTC');
+
+    // The expected values will use the default time.
+    datetime_date_default_time($date);
+
+    // Update the timezone to the system default.
+    $date->setTimezone(timezone_open(drupal_get_user_timezone()));
+
+    // Submit a valid date and ensure it is accepted.
     $date_format = entity_load('date_format', 'html_date')->getPattern();
     $time_format = entity_load('date_format', 'html_time')->getPattern();
 
@@ -119,8 +137,6 @@ function testDateField() {
     $this->assertRaw($date->format($date_format));
     $this->assertNoRaw($date->format($time_format));
 
-    // The expected values will use the default time.
-    datetime_date_default_time($date);
 
     // Verify that the date is output according to the formatter settings.
     $options = array(
@@ -140,7 +156,7 @@ function testDateField() {
             // Verify that a date is displayed.
             $expected = format_date($date->getTimestamp(), $new_value);
             $this->renderTestEntity($id);
-            $this->assertText($expected, format_string('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
+            $this->assertText($expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
             break;
         }
       }
@@ -154,7 +170,55 @@ function testDateField() {
       ->save();
     $expected = $date->format(DATETIME_DATE_STORAGE_FORMAT);
     $this->renderTestEntity($id);
-    $this->assertText($expected, format_string('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+
+    // Verify that the 'datetime_custom' formatter works.
+    $this->displayOptions['type'] = 'datetime_custom';
+    $this->displayOptions['settings'] = array('date_format' => 'm/d/Y');
+    entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
+      ->setComponent($field_name, $this->displayOptions)
+      ->save();
+    $expected = $date->format($this->displayOptions['settings']['date_format']);
+    $this->renderTestEntity($id);
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected)));
+
+    // Verify that the 'datetime_time_ago' formatter works for intervals in the
+    // past.  First update the test entity so that the date difference always
+    // has the same interval.
+    $entity = entity_load('entity_test', $id);
+    $field_name = $this->fieldStorage->getName();
+    $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME - 87654321);
+    $entity->{$field_name}->value = $date->format($date_format);
+    $entity->save();
+
+    $this->displayOptions['type'] = 'datetime_time_ago';
+    $this->displayOptions['settings'] = array(
+      'future_format' => '@time in the future',
+      'past_format' => '@time in the past',
+      'granularity' => 3,
+    );
+    entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
+      ->setComponent($field_name, $this->displayOptions)
+      ->save();
+    $expected = '2 years 9 months 2 weeks in the past';
+    $this->renderTestEntity($id);
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
+
+    // Verify that the 'datetime_time_ago' formatter works for intervals in the
+    // future.  First update the test entity so that the date difference always
+    // has the same interval.
+    $entity = entity_load('entity_test', $id);
+    $field_name = $this->fieldStorage->getName();
+    $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME + 87654321);
+    $entity->{$field_name}->value = $date->format($date_format);
+    $entity->save();
+
+    entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
+      ->setComponent($field_name, $this->displayOptions)
+      ->save();
+    $expected = '2 years 9 months 2 weeks in the future';
+    $this->renderTestEntity($id);
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
   }
 
   /**
@@ -206,7 +270,7 @@ function testDatetimeField() {
             // Verify that a date is displayed.
             $expected = format_date($date->getTimestamp(), $new_value);
             $this->renderTestEntity($id);
-            $this->assertText($expected, format_string('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
+            $this->assertText($expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected.', array('%value' => $new_value, '%expected' => $expected)));
             break;
         }
       }
@@ -220,7 +284,55 @@ function testDatetimeField() {
       ->save();
     $expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
     $this->renderTestEntity($id);
-    $this->assertText($expected, format_string('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+
+    // Verify that the 'datetime_custom' formatter works.
+    $this->displayOptions['type'] = 'datetime_custom';
+    $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A');
+    entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
+      ->setComponent($field_name, $this->displayOptions)
+      ->save();
+    $expected = $date->format($this->displayOptions['settings']['date_format']);
+    $this->renderTestEntity($id);
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected)));
+
+    // Verify that the 'datetime_time_ago' formatter works for intervals in the
+    // past.  First update the test entity so that the date difference always
+    // has the same interval.
+    $entity = entity_load('entity_test', $id);
+    $field_name = $this->fieldStorage->getName();
+    $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME - 87654321);
+    $entity->{$field_name}->value = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
+    $entity->save();
+
+    $this->displayOptions['type'] = 'datetime_time_ago';
+    $this->displayOptions['settings'] = array(
+      'future_format' => '@time from now',
+      'past_format' => '@time earlier',
+      'granularity' => 4,
+    );
+    entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
+      ->setComponent($field_name, $this->displayOptions)
+      ->save();
+    $expected = '2 years 9 months 2 weeks 3 hours earlier';
+    $this->renderTestEntity($id);
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
+
+    // Verify that the 'datetime_time_ago' formatter works for intervals in the
+    // future.  First update the test entity so that the date difference always
+    // has the same interval.
+    $entity = entity_load('entity_test', $id);
+    $field_name = $this->fieldStorage->getName();
+    $date = DrupalDateTime::createFromTimestamp(REQUEST_TIME + 87654321);
+    $entity->{$field_name}->value = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
+    $entity->save();
+
+    entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
+      ->setComponent($field_name, $this->displayOptions)
+      ->save();
+    $expected = '2 years 9 months 2 weeks 21 hours from now';
+    $this->renderTestEntity($id);
+    $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
   }
 
   /**
@@ -391,7 +503,6 @@ function testDefaultValue() {
    * Test that invalid values are caught and marked as invalid.
    */
   function testInvalidField() {
-
     // Change the field to a datetime field.
     $this->fieldStorage->setSetting('datetime_type', 'datetime');
     $this->fieldStorage->save();
@@ -417,7 +528,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => '00:00:00',
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid year value %date has been caught.', array('%date' => $date_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid year value %date has been caught.', array('%date' => $date_value)));
 
     $date_value = '2012-75-01';
     $edit = array(
@@ -425,7 +536,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => '00:00:00',
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid month value %date has been caught.', array('%date' => $date_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid month value %date has been caught.', array('%date' => $date_value)));
 
     $date_value = '2012-12-99';
     $edit = array(
@@ -433,7 +544,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => '00:00:00',
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid day value %date has been caught.', array('%date' => $date_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid day value %date has been caught.', array('%date' => $date_value)));
 
     $date_value = '2012-12-01';
     $time_value = '';
@@ -451,7 +562,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => $time_value,
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid hour value %time has been caught.', array('%time' => $time_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid hour value %time has been caught.', array('%time' => $time_value)));
 
     $date_value = '2012-12-01';
     $time_value = '12:99:00';
@@ -460,7 +571,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => $time_value,
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid minute value %time has been caught.', array('%time' => $time_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid minute value %time has been caught.', array('%time' => $time_value)));
 
     $date_value = '2012-12-01';
     $time_value = '12:15:99';
@@ -469,7 +580,7 @@ function testInvalidField() {
       "{$field_name}[0][value][time]" => $time_value,
     );
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertText('date is invalid', format_string('Invalid second value %time has been caught.', array('%time' => $time_value)));
+    $this->assertText('date is invalid', SafeMarkup::format('Invalid second value %time has been caught.', array('%time' => $time_value)));
   }
 
   /**
diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php
index 2175cb0..6058cce 100644
--- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php
+++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php
@@ -157,79 +157,79 @@ public function testEntityDisplaySettings() {
       'target' => '0',
     );
     $component = $display->getComponent('field_test_link');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     $expected['settings']['url_only'] = FALSE;
     $expected['settings']['url_plain'] = FALSE;
     $display = entity_load('entity_view_display', 'node.story.teaser');
     $component = $display->getComponent('field_test_link');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test the file field formatter settings.
     $expected['weight'] = 8;
     $expected['type'] = 'file_default';
     $expected['settings'] = array();
     $component = $display->getComponent('field_test_filefield');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     $display = entity_load('entity_view_display', 'node.story.default');
     $expected['type'] = 'file_url_plain';
     $component = $display->getComponent('field_test_filefield');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test the image field formatter settings.
     $expected['weight'] = 9;
     $expected['type'] = 'image';
     $expected['settings'] = array('image_style' => '', 'image_link' => '');
     $component = $display->getComponent('field_test_imagefield');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     $display = entity_load('entity_view_display', 'node.story.teaser');
     $expected['settings']['image_link'] = 'file';
     $component = $display->getComponent('field_test_imagefield');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test phone field.
     $expected['weight'] = 13;
     $expected['type'] = 'basic_string';
     $expected['settings'] = array();
     $component = $display->getComponent('field_test_phone');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test date field.
     $expected['weight'] = 10;
     $expected['type'] = 'datetime_default';
     $expected['settings'] = array('format_type' => 'fallback');
     $component = $display->getComponent('field_test_date');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     $display = entity_load('entity_view_display', 'node.story.default');
     $expected['settings']['format_type'] = 'long';
     $component = $display->getComponent('field_test_date');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test date stamp field.
     $expected['weight'] = 11;
     $expected['settings']['format_type'] = 'fallback';
     $component = $display->getComponent('field_test_datestamp');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     $display = entity_load('entity_view_display', 'node.story.teaser');
     $expected['settings'] = array('format_type' => 'medium');
     $component = $display->getComponent('field_test_datestamp');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test datetime field.
     $expected['weight'] = 12;
     $expected['settings'] = array('format_type' => 'short');
     $component = $display->getComponent('field_test_datetime');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     $display = entity_load('entity_view_display', 'node.story.default');
     $expected['settings']['format_type'] = 'fallback';
     $component = $display->getComponent('field_test_datetime');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
 
     // Test a date field with a random format which should be mapped
     // to datetime_default.
     $display = entity_load('entity_view_display', 'node.story.rss');
     $expected['settings']['format_type'] = 'fallback';
     $component = $display->getComponent('field_test_datetime');
-    $this->assertIdentical($expected, $component);
+    $this->assertEqual(ksort($component), ksort($expected));
     // Test that our Id map has the correct data.
     $this->assertIdentical(array('node', 'story', 'teaser', 'field_test'), entity_load('migration', 'd6_field_formatter_settings')->getIdMap()->lookupDestinationID(array('story', 'teaser', 'node', 'field_test')));
   }
